Want a Free Job Posting?

Buy a job posting today and the second one is on us. For a limited time only. Act Now.

Interview Question


Write a function which determines if there is a cycle in a


Interview Answer

1 Answer


Use two pointers. One pointer moves to the next node, the other one moves to the next node's next node in every iteration. If these two nodes match at some point, then you have a cycle. If you reach to the end of the linked-list without a match, then there is no cycle.

Interview Candidate on Feb 26, 2012

Add Answers or Comments

To comment on this, Sign In or Sign Up.