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.
Update: As the problem looks like it need a data structure like cache to hold elements and perform operations. LinkedHashMap may be suitable to implement this as insertion and deletion are easy on it.
My below code is written using ArrayList and I am creating a result list every time when insert request comes which is not optimal.
Previously:
Possibility-1: This problem is combination of merge intervals and insert intervals case if the problem says the problem start with list of unsorted intervals.
Possibility-2 : If the problem is to assume one interval comes at a time as input, then it is straight forward insert interval case.
Java Solution:
Interval object can be stored as below.
Key points:
1. As the question is not clear, if the intervals are sorted or not incase of more intervals as a preprocessing step.
We can take initial List of initial set of inputs and sort them and merge them and keep it ready.
This can be a preprocessor step.
Merge (preprocess step) can be like below
2. After step-1, for every new interval, it is a insert interval scenario (data is already sorted in step-1)
- joboj January 22, 2017