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.
By minimizing |a-b|+|b-c|+|c-a|, the question is asking for the minimum range of one number from each array.
First I would sort each array, then simultaneously iterate through each array, advancing the position in the array which is looking at the minimum value compared to the positioned values in the other arrays. Each iteration would set a,b,c if a minimum range is found. The iteration would stop when the minimum positioned value is at the end of an array, whereby further looking at values would only increase the range.
This should run in O(nlogn) time (from sorting), where n is the length of the longest array out of A,B, or C and O(c) space complexity.
- johnsgresham September 16, 2015Parts could be "cleaned up" if the approach was abstracted to any number of input arrays, not just three.