Smallest Price Range Covering an Offer From Every Seller Feed
Last updated: November 29, 2026
Quick Overview
There are k sellers, each with a sorted list of offer prices for the same product. Find the smallest range [lo, hi] that includes at least one price from every seller; break ties by the smaller lo.
Amazon
November 29, 20260
0
0 solved
There are k sellers, each with a sorted list of offer prices for the same product. Find the smallest range [lo, hi] that includes at least one price from every seller; break ties by the smaller lo.
A Hard heap problem that suits Amazon's multi-seller marketplace: finding a tight price band that every seller can match. Interviewers look for the k-way merge pointer idea with a running maximum, and why advancing only the minimum is correct.
What the Interviewer Expects
- Track one pointer per seller list
- Keep a min-heap of current values and a running maximum
- Evaluate the range at each step and advance the minimum's pointer
- Stop when any list is exhausted
- State O(N log k) time where N is the total number of prices
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 solve it with a sliding window over a merged list?
- What if the lists were streams too big for memory?
- How would you require at least two prices from each seller?
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: k >= 1 non-empty sorted lists of integers. Output: [lo, hi] of minimum hi - lo such that every list has a value in [lo, hi]; ties choose the smaller lo....
High-Level Design
Place the first element of every list in a min-heap of (value, list, index) and track cur_max, the largest value among them. The current heap always holds one element per list, so [heap min, cur_max] ...