Find the Duplicate Number
nums holds n + 1 numbers, each between 1 and n. Exactly one value is repeated (it may appear more than twice); every other value appears once or not at all.
Return the repeated value. Do not change nums.
Example 1
nums [1,3,4,2,2]
returns 2
2 appears twice.
Example 2
nums [3,3,3,3,3]
returns 3
Repeated many times.
Constraints
2 <= len(nums) <= 30- Exactly one value is repeated.
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.