Re: [algogeeks] Re: FInd unique element.

2013-03-12 Thread Nishant Pandey
i think what aditya suggested is cool but in that instead of going for largest element we need to search smallest value and its index would he number we are looking for. On Sun, Feb 24, 2013 at 7:45 PM, Dave dave_and_da...@juno.com wrote: @Marti: If you know m and k, and if m is even and k is

[algogeeks] Re: FInd unique element.

2013-02-24 Thread Dave
@Marti: If you know m and k, and if m is even and k is odd, then xoring the elements of the array will give the integer that occurs k times. But this is not a general algorithm for arbitrary m and k. Dave On Sunday, February 24, 2013 1:24:23 AM UTC-6, marti wrote: A hint is to use XOR for

[algogeeks] Re: FInd unique element.

2013-02-23 Thread marti
A hint is to use XOR for linear time..but how? On Friday, February 22, 2013 12:58:07 AM UTC+5:30, 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

[algogeeks] Re: FInd unique element.

2013-02-22 Thread Aditya Goel
Find the Largest Element in the Array and create an array of that size. now scan the given array and increment the corresponding index of the new array search for the largest number in the new array and the corresponding index is the number that is repeated most number of times. On Thursday,

Re: [algogeeks] Re: FInd unique element.

2013-02-22 Thread Karthikeyan V.B
@Aditya : Since km and we need the element that apears exactly k times, i think u need to find the smallest number in the array and the corresponding index is the number that is repeated most number of times. -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: FInd unique element.

2013-02-22 Thread Saurabh Paliwal
So far what aditya mentioned is I think the best and the most intuitive approach. O(nlog(n)). On Fri, Feb 22, 2013 at 11:22 PM, Karthikeyan V.B kartmu...@gmail.comwrote: @Aditya : Since km and we need the element that apears exactly k times, i think u need to find the smallest number in the

Re: [algogeeks] Re: FInd unique element.

2013-02-22 Thread Saurabh Paliwal
So far what atul mentioned is I think the best and the most intuitive approach. O(nlog(n)). On Fri, Feb 22, 2013 at 11:22 PM, Karthikeyan V.B kartmu...@gmail.comwrote: @Aditya : Since km and we need the element that apears exactly k times, i think u need to find the smallest number in the