14. Detect a Cycle in a Linked List
EasyLinked lists
Return true if the linked list contains a cycle. Use O(1) extra memory.
The tests write the list as { values, pos }: the tail links to the node at index pos, or to nothing when pos is -1.
Example 1
Input: values = [3, 2, 0, -4], pos = 1 Output: true
Constraints
0 ≤ nodes ≤ 10⁴