Maximize Revenue From Non-Overlapping Ad Placement Bookings
Last updated: November 29, 2026
Quick Overview
Advertisers request bookings of a homepage takeover slot, each with a start time, end time and payment. Choose non-overlapping bookings to maximize total revenue.
0
0
0 solved
Advertisers request bookings of a homepage takeover slot, each with a start time, end time and payment. Choose non-overlapping bookings to maximize total revenue.
Weighted interval scheduling appears in Google onsite rounds framed around ad inventory. Interviewers expect sorting by end time, a binary search for the last compatible booking, and a 1D DP over the sorted list.
What the Interviewer Expects
- Show that greedy by earliest end or highest pay fails with weights
- Sort bookings by end time
- Define best[i] over the first i bookings in that order
- Find the last compatible booking with binary search
- Reconstruct the chosen set
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
- Two identical slots are available instead of one.
- Bookings arrive online and must be accepted or rejected immediately.
- Times are touching: does a booking ending at 5 conflict with one starting at 5?
- Add a required gap of g minutes between bookings.
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, pay) with start < end. Bookings [s1, e1) and [s2, e2) conflict if they overlap; a booking ending at t is compatible with one starting at t. Output the max total pay. Greedy...
High-Level Design
Sort by end time. Let best[i] be the max revenue using only the first i bookings. For booking i - 1 (zero-based), either skip it (best[i-1]) or take it and add the best among bookings that end at ...