← 返回 amazon 的题目列表Find the Duplicate Number
类型:online_judge
Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive, return the duplicate number. You must not modify the array and use only constant extra space.
Input
nums: A list of n + 1 integers.
Output
Return the duplicate number.
Example
Input: [1,3,4,2,2] Output: 2
Input: [3,1,3,4,2] Output: 3
Constraints
2 <= n <= 100000
Every integer in nums appears once or twice only.
Example
Input
[1,3,4,2,2]