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.

modulo has a distributive property

- Saurabh July 11, 2018(a * b) % n is equivalent to (a % n * b % n) % n

pow(a,b) is basically multiply a with each other b number of times. so instead of calculating pow(a,b) first which will be a huge number since b is larger than long range, we first calculate a % n and then that value we multiple b numbers of times.

Every time a%n times b goes above long range, we take the % again ... here is a simplified example for clarity

a = 5 b = 4 and n = 3

pow(5,4) % 3

which is the same as

= (5 * 5 * 5 * 5) % 3

= 625 % 3

= 1

assuming pow(5,4) goes above the range, we can also write pow(5,4) % 3 using 5%3 approach like below

= (5 * 5 * 5 * 5) % 3

= (5%3 * 5%3 * 5%3 * 5%3) % 3

since 5%3 = 2, equation becomes

= (2 * 2 * 2 * 2) % 3

= (4 * 4) mod 3 --> here assuming 4 * 4 goes above long range, we take mod again

= (4 % 3 * 4 % 3) % 3

= (1 * 1) % 3

= 1