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. Find and return this duplicate number.
You must solve this problem without modifying the array nums and using only constant extra space.
Example 1:
Input: nums = [1, 3, 4, 2, 2]
Output: 2
Explanation: The number 2 appears twice, so it is the duplicate.
Example 2:
Input: nums = [3, 1, 3, 4, 2]
Output: 3
Explanation: The number 3 appears twice, so it is the duplicate.
Example 3:
Input: nums = [1, 1]
Output: 1
Explanation: The only possible number is 1, and it appears twice.
1 <= n <= 10^5nums.length == n + 11 <= nums[i] <= nnums, but it could be repeated more than once.