Medium · Arrays
Find the Duplicate Number
Given an array nums of n + 1 integers, each in the range 1..n, in which exactly one value repeats (possibly more than twice), return that repeated value without modifying the array.
Examples
Example 1
[1,3,4,2,2]Output: dup = 2
Example 2
[3,1,3,4,2]Output: dup = 3
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.