Given the head of a linked list, determine if the list has a cycle. A cycle exists if some node can be reached again by continuously following next pointers.
With a list 1 → 2 → 3 → 4 where node 4 points back to node 2, return true. The tail connects back into the list, creating a cycle.
With 1 → 2 → 3 → null, return false. The list ends normally.
How can you detect a cycle without using extra space to track visited nodes?
Constraints: .