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.
if you have a linkedIn phone interview, mostly this question will be asked to you.
- snoqualmieseattle December 12, 2012provide the simple solution first
while loop (b times)
{
result = result*a
}
Then note that it might be possible to divide this into smaller recursive problem.
we can use the property that a^b = (a^2)^(b/2)
here we square a, and divide b by 2. In doing this we divide the problem space into half.
so essentially,
when b i s even
pow(a,b) = pow(a^2, b/2);
when b is odd
pow(a, b) = a*pow(a^2, b/2);
Based on above, provide a recursive solution.
Then note that recursion uses stack - which is essentially extra memory.
To save on memory usage, we can convert this implementation into an iterative one.
and then provide the solution with while loop.
If you still have time, then note that
for odd and even b, right shifting the bits by one is equivalent to dividing b by 2.so use b=b>>1, instead of division.
also note that one can check if b is even or odd by this bit operation: if(b&01 === 1) implies that b is odd.