Google Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

2^(n - 1) - 1

- glebstepanov1992 February 10, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Could you please explain how to come up with the formula?

- Guy February 10, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

We hav n bits. in that case you can fit (2^n) - 1 numbers, but in case of signed numbers you use one bit for sign. So you have n - 1 bits. That where formula comes from.

- glebstepanov1992 February 10, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Assume the size of int is n (bits), the largest number that can fit there is 2^(n) - 1.

- tomnebula February 10, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

it depends on whether we use signed or unsigned numbers.

- glebstepanov1992 February 10, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Given n bits.

Unsigned:
2^n - 1

Signed
2^ ( n - 1) - 1

In signed the first one bit is used to represent sign.

How? Given n bits, the number of combinations the bits can take are 2^n. -1 is to account for 0.

- Rushabh October 12, 2014 | 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