Drop the Fewest Sponsored Slots So No Two Overlap
Last updated: November 29, 2026
Quick Overview
An ads scheduler has a list of sponsored placement windows [start, end) on a single feed slot. Return the minimum number of windows to remove so the remaining ones never overlap.
Meta
November 29, 20260
0
0 solved
An ads scheduler has a list of sponsored placement windows [start, end) on a single feed slot. Return the minimum number of windows to remove so the remaining ones never overlap.
A greedy interval problem in the style of a Meta onsite coding round, framed around a single premium feed placement that can show one sponsor at a time. The interviewer is looking for the earliest-end-time greedy and, ideally, a short exchange argument for why it is optimal.
What the Interviewer Expects
- Reframes the problem as keeping the maximum number of compatible windows
- Sorts by end time rather than start time and explains why
- Gives an exchange argument for the greedy's optimality
- Treats touching windows [1,2) and [2,3) as compatible
- Counts removals as n minus kept
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 each window has a bid and you want maximum revenue instead of maximum count?
- How would you return which windows to drop, not just how many?
- With k identical slots, how does the greedy change?
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) windows. Output: the minimum number to delete so the rest are pairwise non-overlapping. Half-open semantics mean windows that only touch are fine. Expect n up to 10^5....
High-Level Design
Minimizing removals equals maximizing the number of windows kept. Sort by end time and greedily keep every window whose start is at or after the end of the last kept window. Why it works: among all wi...