Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Find the Duplicate Number

Medium Arrays

An array of n + 1 integers contains values in the range [1, n] and exactly one value is repeated (possibly more than twice). Print the repeated value without modifying the array and using O(1) extra space.

Constraints

2 <= m <= 10^5 + 1 1 <= nums[i] <= m - 1

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.