Linked List Cycle

Given the head of a linked list, determine whether the list contains a cycle. A cycle exists when some node's next pointer points back to an earlier node, so traversal never reaches null.

The judge represents the list as a values array plus a pos index. It builds a head from values and passes that head together with pos, and it does not connect the tail itself. When pos >= 0, the submitted function must link the tail node's next to the node at index pos before testing; when pos = -1 the list must stay acyclic. pos is always -1 or a valid index into values.

Return true when the resulting list contains a cycle and false otherwise. An empty values array yields an acyclic list.

Examples
Input: [[3,2,0,-4],1]
Output: true
Hints
Related Problems

Linked List Cycle

Given the `head` of a linked list, determine whether the list contains a cycle. A cycle exists when some node's `next` pointer points back to an earlier node, so traversal never reaches `null`.