Shortest Span of a Homepage Row Covering Required Genres
Last updated: November 29, 2026
Quick Overview
A homepage row is a list of titles in display order, each tagged with one genre. Given a set of required genres, return the start and end index of the shortest contiguous span that contains at least one title of every required genre, or None if no span exists.
Netflix
November 29, 20260
0
0 solved
A homepage row is a list of titles in display order, each tagged with one genre. Given a set of required genres, return the start and end index of the shortest contiguous span that contains at least one title of every required genre, or None if no span exists.
Netflix rows are built by ranking models, and a common product check is whether the first visible stretch of a row is diverse enough. This is the minimum window pattern dressed in Netflix's homepage domain, and the interviewer checks the two-pointer invariant and the bookkeeping that makes it linear.
What the Interviewer Expects
- Recognize the minimum covering window pattern
- Track counts per required genre and a covered counter
- Shrink the left pointer while the window remains valid
- Ignore genres that are not required without breaking counts
- Explain why each index enters and leaves the window once
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 answer the same question for every viewport width at once?
- What if each title carries several genres instead of one?
- How would you require at least two titles of a particular genre?
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 genre strings in row order and a set of required genres. Output: (start, end) inclusive indices of the shortest span covering all required genres. Ties go to the earliest span. Return N...
High-Level Design
Expand the right pointer one title at a time, incrementing a count for its genre if it is required. When a required genre's count goes from 0 to 1, increment covered. While covered equals the numb...