Linked Lists

You have a linked list of some length (unknown). You wish to know whether there is a cycle in that link (nodes L1,...,LN such that L1 points to L2, L2 points to L3, and so forth, and LN points to L1). With only O(1) space complexity. How would you go about that?

Solution

Password:
Back to Index