问一道amazon面试题# JobHunting - 待字闺中
M*e
1 楼
原题见这里
http://www.glassdoor.com/Interview/Given-a-list-of-structs-whic
Given a list of structs which include two ids of parent node and the
associated child node, construct a tree.
Interview Candidate: 说
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.
怎么感觉还是不明白.谁知道的给解释一下。
谢谢
http://www.glassdoor.com/Interview/Given-a-list-of-structs-whic
Given a list of structs which include two ids of parent node and the
associated child node, construct a tree.
Interview Candidate: 说
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.
怎么感觉还是不明白.谁知道的给解释一下。
谢谢