Meta Interview Question

python question: given a two dimensional list for example [ [2,3],[3,4],[5]] person 2 is friends with 3 etc. find how many friends does each person has. note one person has no friends. SQL question: find the top 10 college/company that a average social person interacts with. something in those lines. I split the query in two. Not able to finish coding but was able to explain and write both the parts but didn't have time to test it. also had data modeling questions. on a social network website. cant give details.

Interview Answers

Anonymous

Dec 9, 2020

def friends(rels): fs = dict() for r in rels: if len(r) == 1: if r[0] not in fs: fs[r[0]] = 0 else: if r[0] in fs: fs[r[0]] += 1 else: fs[r[0]] = 1 if r[1] in fs: fs[r[1]] += 1 else: fs[r[1]] = 1 return fs

8

Anonymous

Sep 16, 2021

for items in frnd_lst: if len(items)==2: print(f"Person {items[0]} has {items[1]} friends ") else: print(f"Friend {items[0]} has {0} friends")

Anonymous

Nov 16, 2020

answered python question all testcase pass, sql question didn't have time to run and see the result. The interviewer said it is right. data modeling however I think the interview was not too happy. behavioral i think I blabbered too much

1

Anonymous

Nov 18, 2020

Those questions, It was Phonescreen or Onsite ?

Anonymous

Nov 29, 2020

def find_friends(lst): dct = {} for i in range(len(lst)): element = lst[i][0] if len(lst[i]) != 1: dct[element] = dct.get(element,0) + 1 else: dct[element] = 0 return dct

2