# Finding duplicates in array…

An array contains n numbers ranging from 0 to n-1. There are some numbers duplicated in the

array. It is not clear how many numbers are duplicated or how many times a number gets duplicated. How do you

find a duplicated number in the array? For example, if an array of length 7 contains the numbers {2, 3, 1, 0, 2, 5,

3}, the implemented function (or method) should return either 2 or 3.

Indexes in an array with length n are in the range 0 to n-1. If there were no duplication in the n

numbers ranging from 0 to n-1, we could rearrange them in sorted order, locating the number i as the ith

number. Since there are duplicate numbers in the array, some locations are occupied by multiple

numbers, but some locations are vacant.

Now let’s rearrange the input array. All numbers are scanned one by one…

View original post 261 more words

Posted on June 17, 2013, in Algorithms, Programming and tagged Finding duplicates in array. Bookmark the permalink. Leave a comment.

## Leave a comment

## Comments 0