DSAMediumLinked List
Detect a Cycle in a Linked List
đ Problem
Given a linked list, determine whether it has a cycle (a node's next pointer eventually loops back to an earlier node).
đ§ Approach
Use Floyd's Cycle Detection (the 'tortoise and hare' technique): one pointer (slow) moves one step at a time, another (fast) moves two steps at a time. If there's a cycle, the fast pointer will eventually 'lap' the slow pointer and they'll meet. If fast reaches the end (NULL), there's no cycle.