Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null.
The problem is defined with an array representation where each element represents a node value, and its index represents the next pointer. A value of -1 indicates the end of the list.
Examples
Input:[3,2,0,-4]
Output:-1
Input:[1,2]
Output:-1
Hints
Use Floyd's Tortoise and Hare algorithm
First find if a cycle exists
Then find the cycle start using the distance formula