Pergunta de entrevista da empresa Meta

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.

Respostas da entrevista

Sigiloso

9 de dez. de 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

Sigiloso

16 de set. de 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")

Sigiloso

16 de nov. de 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

Sigiloso

18 de nov. de 2020

Those questions, It was Phonescreen or Onsite ?

Sigiloso

29 de nov. de 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