142. Linked List Cycle II

Practice Linked List Cycle II for free on NudgeCode: Medium, Linked List pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Given the head of a linked list, return the node where the cycle begins, or null if there is no cycle. Do not modify the list.

In the tests, pos is the index the tail's next points to (-1 means no cycle), and the expected output is the index of the node you return (-1 for null).

Example

head = [3,2,0,-4], pos = 1  ->  node at index 1

Constraints