Given an array of integers nums containing n+1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums; return this repeated number. You must solve the problem without modifying the array and use only constant extra space.
nums = [1,3,4,2,2]2nums = [3,1,3,4,2]3nums has values 1..n in n+1 slots. Treating value as next-pointer creates a linked list with a cycle at the duplicate. The duplicate value is pointed to by two different indices, so it is the cycle entrance. Floyd's algorithm finds the cycle start in O(n) time and O(1) space — Phase 1 brings both pointers inside the cycle; Phase 2 (reset slow to start, advance both at same speed) guarantees they meet exactly at the cycle entrance.