Given a limited range array of size `n`

where array contains elements between `1`

to `n - 1`

with one element repeating, find the duplicate number in this array.

Let array `arr`

equal to `[ 1, 2, 3, 4, 4 ]`

. The duplicate element in this array is `4`

, therefore the solution should return the integer `4`

.

Let array `arr`

equal to `[ 1, 2, 3, 2, 4 ]`

. The duplicate element in this array is `2`

, therefore the solution should return the integer `2`

.

Contributed by Murat Sütunç

You are not signed in. You can only run/submit code after signing in. Create your free Codela account now!