Measure the length of a linked list's cycle
A traversal has confirmed that a linked list contains a cycle. The next diagnostic question from your monitoring system is: how big is the loop?
1 -> 2 -> 3 -> 4 -> 5
^ |
+---------+ # 5 points back to 3: cycle length 3
Return the number of nodes in the cycle in time and space. Return if there is no cycle.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.