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.
This is a neat problem and @MehrdadAP's solution is excellent. One minor improvement that I'd make is instead of using +1/-1 to keep track of range boundaries, use a Fenwick Tree that uses XOR operator, instead of addition. The running time does not change but this is a little more elegant since you don't have to do any further calculations to find if value is even or odd. The Fenwick Tree would just have 0/1 bit values and cumulative XOR of bit values computes 0/1 results. Here is a video tutorial that explains this in full detail: youtu.be/oAR_EYd8im0
- Stable Sort February 04, 2020One other bonus of this approach is that it uses less space - just a bit array, instead of integer array.