Smallest Score Range Covering One Video From Every Category
Last updated: November 29, 2026
Quick Overview
For a diverse feed slate, you have k lists of candidate video quality scores, one list per content category, each sorted ascending. Find the smallest range [lo, hi] that includes at least one score from every list; break ties by smaller lo.
TikTok
November 29, 20260
0
0 solved
For a diverse feed slate, you have k lists of candidate video quality scores, one list per content category, each sorted ascending. Find the smallest range [lo, hi] that includes at least one score from every list; break ties by smaller lo.
TikTok's ranking applies diversity constraints so a slate includes several categories without dropping quality too far, and this onsite question captures that trade-off. The interviewer looks for the min-heap sweep that keeps one pointer per list and tracks the current maximum.
What the Interviewer Expects
- Keeps exactly one candidate per category in a min-heap
- Tracks the current maximum alongside the heap minimum
- Advances only the list that holds the minimum
- Stops when any list is exhausted and explains why
- Gives O(N log k) 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
- How would you allow skipping up to one category?
- What if the lists are not sorted?
- How would you adapt this when scores update in real time?
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:
lists: list[list[int]], each sorted ascending and non-empty. - Output:
(lo, hi)with minimalhi - lo, ties by smallerlo. - k categories, N total scores....
High-Level Design
Start with the first element of every list in a min-heap and remember the max among them. The range [heap_min, cur_max] covers every list. To try to shrink it, the only useful move is to raise the m...