KatInterview

Streaming Home Feed: Visible-Grid Deduplication

System DesignModel answer
MediumModel answerSystem Designdeduplicationpage-assemblygreedy

Last updated

Design the algorithm and surrounding system that ensures every show tile visible on a streaming home page appears at most once, across all rows and columns.

Context

A streaming platform's home page is a grid of rows — "Popular Now", "Because You Watched X", "New Releases", and so on. Each row is generated independently by a separate ranking service and can contain 50–100 candidate titles in priority order. Because rows are generated independently, the same show can appear in multiple rows at the same time.

Product wants a hard guarantee: no show appears more than once anywhere in the first visible screen. Below the fold and past the horizontal scroll boundary, duplicates are tolerable but should be minimized.

What you're asked to design

  1. Define your terms. What counts as the "visible grid"? What makes two tiles duplicates? What device differences matter?
  2. Propose an algorithm. Walk through the logic step by step. Justify the traversal order you choose.
  3. Place it in a system. Where does this logic live — client, server, or both? How does it fit in the page-assembly pipeline?
  4. Handle edge cases. What happens when a row runs out of unique candidates before filling its visible columns? What if the grid shrinks or grows, for example on a browser resize?
  5. Discuss trade-offs. Greedy vs. global optimization, row-major vs. column-major fill, server-side vs. client-side enforcement, and how you'd validate the change.

A strong answer: states assumptions before diving in, presents a clean working algorithm, correctly characterizes its complexity, and explains what you'd give up with a simpler approach versus what you'd gain with a more expensive one.

Hints

Hint 1

Start by pinning down the two key ambiguities — what 'visible' means per device and what makes two titles the same show — before touching any algorithm. Interviewers look for this grounding step.

Hint 2

Think about traversal order: filling each row left-to-right before moving to the next row is simpler, but filling the entire leftmost column first (column-major) better respects how users actually scan. Work out which order is more defensible and why.

Hint 3

When a row exhausts its unique candidates before filling its visible slots, you have two choices: leave the row short or drop it and promote the next one. Think through what 'dropping a row' means for the seen-set — should those titles stay reserved?