## ashishkaila@hotmail.com

BAN USERI guess I didn't read that we cannot use memory that is proportional to the length of the list. So above approach is ruled out.

- ashishkaila@hotmail.com December 08, 2011Did you understand the question? Or even worse did you understand your answer and the remotest possibility on how it could be related to the question?

- ashishkaila@hotmail.com December 04, 2011This seems correct to me. All bits have equal probability.

- ashishkaila@hotmail.com November 22, 2011This is same as finding common node in Y linked list. Parent pointers correspond to next pointer in this case.

- ashishkaila@hotmail.com November 22, 2011Why not a balanced binary tree? To search for a place to insert and to insert in tree it only takes O(log n) ! Once the book is final, in order traversal can assign page numbers.

- ashishkaila@hotmail.com November 22, 2011a^n = a ^ (n/2) * a ^ (n/2) => if n is even

a * a ^ ((n-1)/2) * a ^ ((n - 1)/2) => if n is odd

Now one can use recursion to calculate one quantity and square it and potentially multiplying it with the number if n is odd.

Ok I don't think any solutions so far is right. Consider the case where the lengths of two lists are equal. In this case one can iterate both head pointers till they point to the same element. Now in the general case where list lengths may not be equal, find both lengths and move the head of the longer list to number of nodes which is equal to the difference of the lengths of two lists. From now on both head lengths are same so you can simply iterate and find the common element. This also works for the case where one list starts in the middle of another list !

- ashishkaila@hotmail.com November 22, 2011Using connection points and containers.

- ashishkaila@hotmail.com November 21, 2011Use JSON :). It is very efficient. Just pre-order cannot construct a unique tree. So above solution is not correct. If you go that route you need in-order traversal as well which doubles up the storage space requirement.

- ashishkaila@hotmail.com November 21, 2011Well if you have string: abb then you can reduce it to cb and then to just a. The answer therefore is 1

- ashishkaila@hotmail.com November 21, 2011**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

First of all, the question is ambiguous. The longest word is made up of itself so is it a candidate? I rule this out for our case.

- ashishkaila@hotmail.com December 08, 2011I would create a trie and put endings for each word. Then simply traverse the trie and report the longest branch that has more than one subset words in it (or keep) track of this stat as you insert words.