118. Find the Duplicate Number

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.
Example 2
Input: nums = [1,3,4,2,2]
Output: 2
Explanation: The duplicate is 2.
arraysbinary searchmedium
JavaScript
Loading...
Line 1, Char 1