← All problems
Find the Duplicate Number
Array of n+1 integers in [1, n] with one duplicate. Find it without modifying the array, O(1) space.
Complexity
Time O(n), Space O(1)
Common pitfalls
- Sorting the array (modifies it)
- Binary-search-on-count is O(n log n) - acceptable but not the intended trick
Your solution
Log in to save your code and track progress.