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

Join Shalyam Newsletter

Get exclusive insights with every issue: education, research and innovation news.

One email a week. Unsubscribe any time.