The Netflix homepage is organized as a vertical list of shelves (rows), where each shelf contains a horizontal list of titles (movies or shows). The horizontal viewport displays at most X titles per shelf — the user can scroll horizontally to see more, but only the first X are visible without interaction. The vertical viewport is treated as infinite (all shelves are visible).
The goal: ensure no title appears more than once across all visible positions on the first screen. If the same title appears in the visible portion of multiple shelves, it should be deduplicated — kept in one shelf and replaced or removed in the others.
This is an open-ended problem solving question. You are expected to clarify the problem, design an algorithm, discuss trade-offs, and write code. Key considerations include: how to decide which shelf keeps the title (priority/ranking), how to handle replacements (shift titles forward, fill from the non-visible portion of the shelf, or leave gaps), and the time/space complexity of your approach.