Just to reword:
n- handle length
l - loop length
x - total length
p = q = head;
move p by l+1 nodes
then move both p and q 1 node till they meet They will meet at the end
of the handle.
Thanks Vinod.
--~--~-~--~~~---~--~~
You received this message because you ar
I am not sure I got it.
Is the list :
1,2,3,4,5,6,7,8,9,10,11,12,13,8 - i.e the loop is at the end which has
to be the case since node 3 cannot have 2 out links?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Alg
s now??
I have a brute force solution like this:
Once I know the length of the loop I can try traversing this length
from all nodes beginning from the handle. The first node for which I
come back after is the node!
Thanks,
Oogle
Singularity wrote:
> Did you detect the exact element that points
How do I find the length of a linked list that has a cycle, after
having detected the cycle?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@go