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.
To expand on algos' answer:
He gives O(log(n)) as the runtime. I explain how to get that:
Suppose the target number is in the range 2^(m-1) -> 2^m - 1.
Then, m comparisons would have to be done first as per algos' algo. So, this takes theta(m) time.
Then, binary search on the range would take O(m) time ( Why? See below. )
So, the total search time would take O(m) time (theta(m) + O(m) = O(m)).
- gigarohan March 30, 2013Suppose the size of the array is n. In the worst-case, the target number would be in the last range and the last range would be "full", i.e. there are numbers in every spot. Then, the last range ends at index 2^(x)-1. And 2^(x)-1 = n-1, so, x = log(n). So, worst-case m would be log(n). So, the search time is O(log(n)), just as algos said.