Pergunta de entrevista da empresa Meta

Give a set of objects and a function. Pass two objects to that function and it can tell you whether one object points to another one. Find one object that is pointed by all other objects.

Respostas da entrevista

Sigiloso

2 de mar. de 2014

Have a set of candidate nodes. Initially this is the set of all nodes. Start with first node. Call the function with arguments as first node and all other nodes. The nodes that point to first node should removed from the candidate set. Then move onto the second node and test it against the candidate set. And so on. At the very end, the set of remaining nodes are the ones that all other nodes point to.

5

Sigiloso

10 de set. de 2014

I don't really get this question. If a node points to the first node, why can't it be a candidate as the first node could also point to that node?

3

Sigiloso

2 de mar. de 2014

The second statement sounds like the compare function that C qsort(...) requires. To address the third, Traversing with node identity hashing seems like a way to solve the problem; where the traversal with the biggest list has the answer. Huge potential to expand. There has to be heuristics to trim the search. What are they?