Amazon Interview Question
SDE1sCountry: India
Interview Type: In-Person
1. User min heap to store the 5 items.
2. Any time anyone emits something:
2.1 If it is from one of those 5 guys, check if distance is increasing or decreasing.
2.1.1. If decreasing, then reheapify.
2.1.2. If increasing, then reheapify followed by a check if any other cab can get into the top 5 or not.
2.2. Check if the car can be put inside the heap or not, heapify.
Run the entire class.
- Not the BEST solution, but it works. July 06, 2016