Given an array of integers `nums` of length `n`, where each element is an integer in the range `[1, n - 1]` inclusive. There is guaranteed to be at least one duplicate integer in the array. Find and return this duplicate number without modifying the original array and using only constant extra space `O(1)`.
Explanation: The number 2 appears twice in the array, so it is returned as the duplicate.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak