Fewest Reservations to Drop So a Driver Has No Conflicts
Last updated: November 29, 2026
Quick Overview
Given a driver's accepted advance reservations as [start, end) intervals that may conflict, return the minimum number to reassign to other drivers so the remaining reservations do not overlap.
Uber
November 29, 20260
0
0 solved
Given a driver's accepted advance reservations as [start, end) intervals that may conflict, return the minimum number to reassign to other drivers so the remaining reservations do not overlap.
When Uber Reserve trips are double-booked after a schedule change, dispatch should keep as many with the original driver as possible. The interviewer checks that you identify the earliest-end-time greedy and can justify it, not just recall it.
What the Interviewer Expects
- Rephrase as keeping the maximum set of non-overlapping intervals
- Sort by end time, not start time
- Prove the greedy choice with an exchange argument
- Handle touching intervals as non-conflicting
- Return which reservations to drop if asked
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- What if reservations have different fares and you want to keep maximum revenue?
- What if the driver can keep two overlapping trips when both are pooled?
- How would you return the dropped reservation ids?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: list of
[start, end)intervals. - Output: minimum number removed so the rest are pairwise non-overlapping. Touching intervals like
[1, 2)and[2, 3)do not conflict....
High-Level Design
Minimizing removals is the same as maximizing kept reservations. Sort by end time and keep a reservation whenever it starts at or after the end of the last kept one. Exchange argument: the reservation...