is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
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.
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.
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.
The & operator can function as either a unary or a binary operator,
- skmr July 09, 2008ex: x = 10; 10 equivalent binary is 1010, so Integer 10 has 2 one bit.
when first and second iteration goes
1st | 2nd
-----------|-------------
1010 (10) | 1000 (8)
x 1001 (9) | x 0111 (7)
----- | -----
1000 (8) | 0000 (0)
----- | -----
so iterator reaches 0 (ie x =0), so there wont be anymore looping, so number of one bit in 10 is 2. and its in O(n) solution.
here is the code.
// C# Code
static int OneBitCount(int x)
{
int counter = 0;
while (x>0)
{
// bit operation
x = x & (x-1);
// increment the counter
counter++;
}
return counter;
}