Medium · Arrays
Find 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
Open every published interview problem, solution, scene, and memory room free, with no account.