Find the Duplicate Number
Input:
[1,3,4,2,2]
Output:
2Input:
[3,1,3,4,2]
Output:
3Note:
You must not modify the array (assume the array is read only).
You must use only constant, O(1) extra space.
Your runtime complexity should be less than O(n2).
There is only one duplicate number in the array, but it could be repeated
more than once.Last updated