Linked List Cycle
Given a linked list with potentially a loop, determine whether the linked list from the first node contains a cycle in it. For bonus points, do this with constant space.
Parameters
nodes
: The first node of a linked list with potentially a loop.
Result
- Whether there is a loop contained in the linked list.
Examples
Example 1
Input:
Output:
true
Example 2
Input:
Output:
false
Constraints
1 <= len(nodes) <= 10^5