Concept Flow - Detect Cycle in Linked List Floyd's Algorithm
Start: head
Initialize slow = head, fast = head
Loop: fast != null and fast.next != null?
NoāNo cycle found, return false
Yes
Move slow by 1 step
Move fast by 2 steps
Check if slow == fast?
YesāCycle detected, return true
ā©Back to Loop
The algorithm uses two pointers moving at different speeds to detect if a cycle exists by checking if they meet.
