In an array of n+1 elements with values from 1..n, find the duplicate.
Example 1
Input: nums = [3,1,3,4,2]
Output: 3
Explanation: The duplicate is 3.
Output: 3
Explanation: The duplicate is 3.
Example 2
Input: nums = [1,3,4,2,2]
Output: 2
Explanation: The duplicate is 2.
Output: 2
Explanation: The duplicate is 2.