141. Linked List Cycle

Practice Linked List Cycle for free on NudgeCode: Easy, 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 whether the list contains a cycle, i.e. some node can be reached again by following next.

In the tests, pos is the index the tail's next points to (-1 means no cycle). pos is not passed to your function.

Example

head = [3,2,0,-4], pos = 1  ->  true

Constraints