Duplicate Element Find Algorithm

posted Dec 23, 2010, 10:33 AM by Unknown user   [ updated Dec 23, 2010, 10:51 AM ]
This algorithm finds a duplicate element in the array (with certain constraints). 

There exists N elements in the array. N-1 elements from 1 to N and one element exists twice. This duplicate element can be found out by the method of maintaining a parallel array which stores the count of the elements in the original array. 

My method of doing the same problem is explained in terms of 2 Examples shown below.