Maximize Profit From Non-Overlapping Lightning Deal Slots
Last updated: November 29, 2026
Quick Overview
Sellers bid for Lightning Deal slots on a single homepage banner. Each bid has a start time, end time and profit; two accepted bids cannot overlap (a bid ending at t can be followed by one starting at t). Return the maximum total profit.
Amazon
November 29, 20260
0
0 solved
Sellers bid for Lightning Deal slots on a single homepage banner. Each bid has a start time, end time and profit; two accepted bids cannot overlap (a bid ending at t can be followed by one starting at t). Return the maximum total profit.
A weighted interval scheduling question in the style of Amazon onsite rounds, set in retail deals. The interviewer wants a sort-by-end DP with binary search for the latest compatible bid and a clear explanation of why greedy by profit or by end time fails.
What the Interviewer Expects
- Show why greedy by end time or by profit fails
- Sort bids by end time
- Define dp[i] as best profit using the first i bids
- Binary search for the last compatible bid
- Optionally reconstruct the chosen bids
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
- How would you return which bids were accepted?
- What if the banner has two slots that can run concurrently?
- How would you handle bids arriving online?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Bids are (start, end, profit) with start < end and profit > 0. Touching endpoints are compatible. Return an int....
High-Level Design
Sort by end. Let ends be the sorted end times. For the i-th bid (0-indexed), the latest compatible earlier bid is the number of bids whose end <= start_i, found with `bisect_right(ends, start_i, 0, ...