Maximize Revenue From Non-Overlapping Bids on a Yahoo Homepage Slot
Last updated: November 29, 2026
Quick Overview
Advertisers bid for exclusive time ranges [start, end) on a premium Yahoo homepage placement, each with a price. Choose a set of non-overlapping bids that maximizes total revenue and return both the revenue and the chosen bids.
Yahoo
November 29, 20260
0
0 solved
Advertisers bid for exclusive time ranges [start, end) on a premium Yahoo homepage placement, each with a price. Choose a set of non-overlapping bids that maximizes total revenue and return both the revenue and the chosen bids.
Yahoo sells guaranteed, reserved placements such as homepage takeovers alongside programmatic ads. This weighted interval scheduling problem checks that you reject the greedy earliest-end solution, set up a DP over bids sorted by end time, and use binary search for the compatible predecessor.
What the Interviewer Expects
- Explain why greedy by end time or by price fails with weights
- Sort by end time and define dp[i] over the first i bids
- Use binary search to find the last bid ending at or before the current start
- Reconstruct the chosen set from stored decisions
- State O(n log n) time
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 the slot can show two ads at once?
- How would you add a constraint of at most one bid per advertiser?
- How would you handle bids arriving online with a deadline to accept or reject?
- How would you break ties between equal-revenue schedules?
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, price) with end exclusive, so (0,3) and (3,6) are compatible. Output: (max_revenue, chosen_bids)....
High-Level Design
Greedy by earliest end maximizes the number of bids, not revenue, and greedy by price can block two medium bids that together earn more. Instead:
Sort by end time. Let be the best revenue usi...