Re: [algogeeks] Array of intergers with repeating elements

2013-05-16 Thread Kalyanasundaram
Check this out. The first answer is the most efficient one. You find each bit of the number, by using modulo operator. http://stackoverflow.com/questions/9442958/find-the-element-occurring-b-times-in-an-an-array-of-size-nkb On Wed, May 8, 2013 at 2:40 PM, Nishant Pandey

Re: [algogeeks] Array of intergers with repeating elements

2013-05-14 Thread bharat b
@ Jatin : N elements occur k times - there are N distinct elements and total of N*k elements.. one element occurs b times - there are b elements and one distinct element .. totally N+1 distinct elements and N*k + b elements are there ... On Wed, May 8, 2013 at 1:14 AM, jatin luthra

Re: [algogeeks] Array of intergers with repeating elements

2013-05-12 Thread Nishant Pandey
i think u should utilize the property of XOR, this would help. On Wed, May 8, 2013 at 12:02 AM, MAC macatad...@gmail.com wrote: I was asked this in recent amazon onsite interview and asked o write code Given an Array of integers . N elements occur k times and one element occurs b times, in

Re: [algogeeks] Array of intergers with repeating elements

2013-05-12 Thread jatin luthra
N elements occur k times and one element occurs b times, in other words there are n+1 distinct Elements didn't get this statement On Wed, May 8, 2013 at 12:02 AM, MAC macatad...@gmail.com wrote: I was asked this in recent amazon onsite interview and asked o write code Given an Array of

Re: [algogeeks] Array of intergers with repeating elements

2013-05-12 Thread Ankit Sambyal
Are these n+1 elements range from 1 to n+1 ? On Wed, May 8, 2013 at 12:02 AM, MAC macatad...@gmail.com wrote: I was asked this in recent amazon onsite interview and asked o write code Given an Array of integers . N elements occur k times and one element occurs b times, in other words

[algogeeks] Array of intergers with repeating elements

2013-05-07 Thread MAC
I was asked this in recent amazon onsite interview and asked o write code Given an Array of integers . N elements occur k times and one element occurs b times, in other words there are n+1 distinct Elements. Given that 0 b k find the element occurring b times. We know k is NOT even . thanks