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
Coding & Algorithms
Software Engineer
Yahoo
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

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
weighted interval scheduling
1D dynamic programming
binary search
sorting
ad auctions
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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 dp[i]dp[i] be the best revenue usi...


Submit Your Answer
Markdown supported

Related Questions