You need to log in or create an account to post to this user's Wall.
int noofOnes(int n)
{
int c=0;while(n)
{
c++;
n=n&(n-1); // remove the right most 1 }
return c;
}Are you sure that numbers are stored as MAx heap…..
There is a method to find kth element in O(n) called selection method
This is nothing but variation of quicksort ….where partition is always in balanced way
Gautam joined the group Amazon Interview 1 year, 2 months ago
Nth Fib number will be
Fn = ((1+sqrt(5))^n – (1-sqrt(5)) ^ n ) / 2^n *sqrt(5); // derived using recurrence relation
now the only thing is finding n
where mod | Fn – N| minimum
We can use kind […]
Gautam became a registered member 1 year, 3 months ago
