How to find loop-node of a linkedlist with a loop?
This question is a bit different than finding an intersection of 2 linked
lists.
Consider a linkedlist with a loop: A - B - C - D - E - F - C.
If node A is the input to the function, then it should return C.
Since I do not know what to call C, I have used a term loop-node C as seen
in the question. Although an O(n2) term appears obvious, can there be a
way to find loop-node with lesser complexity?
A hash table / extra space of O(n) not allowed.
No comments:
Post a Comment