noname

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.
Assuming user requests are not known and come at random, the requests can be scheduled according to their callback time.
i. e. if the user creates timer at t as timer.startTimer(x, callback), then (t+x) is the callback time when the user will get callback.
So we maintain a min heap using callback time as the priority criteria and select request with most recent callback time to be scheduled with the system timer. We keep adding to the heap when new request for creating timer arrives.
But there are certain edge cases. For example, if a user creates a timer at time t as timer.startTimer(3,callback) and at (t+1) creates another timer as timer.startTimer(1,callback), then the second request should be scheduled to the system timer before the first request (t+1+1 < t+3) because otherwise it cannot be scheduled. If the first request is assigned to the system timer as soon as it arrives, the second request cannot be satisfied. So, we remove remove from priority queue only when the callback time is 1 second later.
Time complexity for n requests: O(nlogn)
- noname May 03, 2019