Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive, there is exactly one repeated number in nums. Return this repeated number.
You must solve the problem without modifying the array and uses only constant extra space.
Input: nums = [1, 3, 4, 2, 2] Output: 2 Explanation: The number 2 appears twice.
Input: nums = [3, 1, 3, 4, 2] Output: 3 Explanation: The number 3 appears twice.
1 <= n <= 10^5nums.length == n + 11 <= nums[i] <= nnums, but it could be repeated more than twice.nums = [1, 3, 4, 2, 2]