9.Linked List Cycle
Problems related to Cycle Detection in Linked List
Determine if a Linked List has a cycle in it.
This algorithm is based on Floyd’s Cycle-Finding Algorithm. Time complexity O(n) and Space Complexity O(1).
This can also be solved using hash tables but we require an extra space of O(n).
Determine the node where the cycle begins
This solution also includes the same cycle finding approach.
First, find the position where the two pointers meet.
Then we move one pointer to the head
Iterate each pointer by one step.
Determine the length of the cycle
Last updated