Pergunta de entrevista da empresa Amazon

Given a list of structs which include two ids of parent node and the associated child node, construct a tree.

Resposta da entrevista

Sigiloso

25 de jun. de 2011

The solution should use O(n) time and O(n) space. The idea is to hash ids (parent id - child id). The the linear scan constructs the tree.