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
@ 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
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
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
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
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