Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
3
of 3 vote

int fun(int n)
{
int count=0;
if(n!=0)
{
 do
     {
       count++;
       n&=n-1;
      }while(n);
return count;
}

- Livin D'cruz March 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Beautiful

- Anonymous April 17, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static int count(int n)
{
int count=0;
for(;n!=0;n=n>>1)
count+=n&1;
return count;

}

- Ankita Juhi March 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

a tricky problem although it is ooold

- yu March 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int countInt(int n){
int count = 0;
while(n){
n&=n-1;
count++;
}
return count;
}

- yashsheth46 March 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

you need to initialize count=1

- SuperM March 12, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int checkSetBit(int val)
{
int count=0;
while(val>0)
{
if(val%2==1)
count++;
val=val>>1;
}
printf("No. of set bit is %d",count);
}

- Pradip(Tezpur University) March 12, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

small change in code

int checkSetBit(int val)
{
int count=0;
while(val>0)
{
if(val%2==1)
count++;
val=val>>1;
}
return count;
}

- Pradip(Tezpur University) March 12, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int BitCount(unsigned int u)
 {
         unsigned int uCount;

         uCount = u
                  - ((u >> 1) & 033333333333)
                  - ((u >> 2) & 011111111111);
         return
           ((uCount + (uCount >> 3))
            & 030707070707) % 63;
 }

- Arpit June 04, 2012 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More