Assuming that : all numbers of the array range from [0,n-1]
Copy array A to B
Make all integers negative
Scan the array while B[B[i]] = B[B[i]] + n
Now scan the array for the smallest non-negative element : element of
original array having the index of the smallest element is the element that
use hashmap
On Fri, Feb 22, 2013 at 12:58 AM, marti wrote:
> How do I Find the Unique Element that Appears exactly k Times in an Array?
> the problem is given an integer array, only one integer appears* k* times,
> all the other integers appears *m* times in the array (*k*<*m*). Find out
> that
How do I Find the Unique Element that Appears exactly k Times in an Array?
the problem is given an integer array, only one integer appears* k* times,
all the other integers appears *m* times in the array (*k*<*m*). Find out
that integer.
--
You received this message because you are subscribed