Removing even/odd numbers in problem 5.7 of cracking the coding interview




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

Step 3 removes non-candidate numbers. If a missing number ith bit is 0, it cannot be any numbers whose ith bit is 1. By removing number whose ith bit is 1, it reduces the candidate number by half.
Example: Suppose the missing number V is 000. if 0th bit of V is 0, V cannot be any numbers whose 0th bit is 1. Thus 001 and 011 are removed.
- - -
001
010
011

- ibn Humboldt July 21, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

testing

- ss July 21, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

msg

- po July 21, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In my opinion, the question is very poorly worded. It says the numbers can only be accessed one bit at a time in constant time. But then allows copying the numbers into two different arrays in O(n) time (each number is copied in constant time) instead of O (n log n) time (where each number needs to have all it's bits copied in O(log n) time).

- Jackfruit September 30, 2018 | 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