zbesst
BAN USER
Comments (5)
Reputation 55
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
@oOZz
I should have said graph, and assumed the problem was modeled as such. It was a bad assumption to say "tree" rather than "graph".
It could also be any other data structure where an element is referred to as a "node." The problem itself doesn't specify a data structure.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
1) Use a HashSet or equivalently
- zbesst June 19, 20132) Use a HashTable that maps a[i] -> # of occurrences, then print all keys.
Both are O(n) time and space.