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 should be possible in O(n^2) time and space complexity.
- LionelSeidman1 November 01, 2018First, you can rewrite the equation as x + y = w - z. Then create a nested loop where you calculate every possible value of x + y (ensuring the y-index always exceeds the x-index), and insert those values into a dictionary with the xy sum as the key. The dictionary value in this case would be an array containing the index of y. If you get xy sums that match existing keys, just add the new y index of those sums to the array returned by the dictionary.
Next, create an integer counter, and then create a second nested loop over the array, in which you'll compute every possible value of w - z (ensuring the w-index always exceeds the z-index). For each computed value, check the dictionary for a match. If you get one, loop over the returned array, and for each value that is less than your current z-index, increment the counter by 1.