Given an array of n+1 integers where each integer is in [1, n], find the duplicate number without modifying the array and using O(1) extra space.
Input: nums=[1,3,4,2,2] Output: 2 Input: nums=[3,1,3,4,2] Output: 3
Unlock hints progressively — start gentle, go deeper only if needed.
Level 1: Gentle Nudge
A subtle direction
Level 2: Approach
The algorithm to use
Level 3: Detailed
Step-by-step guidance
to save progress and use AI features