Amazon.com
3.4 of 5 2,795 reviews
www.amazon.com Seattle, WA 5000+ Employees

Amazon.com Software Development Engineer I Interview Question

I interviewed in Seattle, WA and was asked:
"Write a function that takes an integer and counts the number of bits."
Tags: algorithm, bit manipulation
Add Tags [?]
Answer Flag Question

Part of a Software Development Engineer I Interview Review - one of 4,129 Amazon.com Interview Reviews

Answers & Comments

0
of 0
votes
This is a simple bit manipulation problem. If you study before your interviews, this is a common area to study.
- Interview Candidate on Jan 14, 2012 Flag Response
0
of 0
votes
void count_Bits(int inp){
    int count = 0;

    for (int y = inp; y >=1;y = y /2 ){
        count++;
    }

    cout<< "number of bits : " << count<< endl;

}
- karan on Nov 17, 2012 Flag Response
0
of 0
votes
If you take a simple log base 2 of the integer, that should give you the number of bits, right?
- Anonymous on Jul 21, 2013 Flag Response

To comment on this question, Sign In with Facebook or Sign Up


Tags are like keywords that help categorize interview questions that have something in common.

Glassdoor is your free inside look at Amazon.com interview questions and advice. All interview reviews posted anonymously by Amazon.com employees and interview candidates.