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
.