ask4prasath
BAN USER
Comments (4)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
Put it into a stack when a sub process is created.
- ask4prasath July 10, 2012Comment hidden because of low score. Click to expand.
0
of 0 vote
What kind of traversal algorithm you can use. guess this will end into infinite loop.
- ask4prasath July 10, 2012Comment hidden because of low score. Click to expand.
0
of 0 vote
Take any person and get all the peoples he knows.
Consider there 1..n people and person 1 knows k people (k <= n)
then we just have to iterate the k people and return the person who doesnt know anybody.
This will solve the problem in O(k + 1)
The worst case will be O(n) if person knows all the people.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
step 1: Make a suffix trie of the string complexity O(n)
- ask4prasath July 19, 2012step 2 reverse the string no extra complexity can be reversed along with step 1
step 3: check the reversed string with with trie