1/28
Part 1 of 6 · The screen as a setLearn

No repeated titles on the first screen

Netflix software engineer candidates report a homepage dedup question. One got it in a technical screen and had to write their own test cases after the code (1 report). Another got it in a phone screen that was more about talking it through than about code (1 report), and a third report lists only its title (1 source). It starts like this:

The homepage is a list of rows, top to bottom. Each row is a list of title ids, best first. The first screen shows the first width titles of every row.

Write dedup_homepage(rows, width). Fill each row's slots left to right with the row's best title that isn't on the screen yet. After the slots, the rest of the row follows in its order, with no title twice in one row. If no title fits a slot, the row ends there.

With width = 2:

  • [["A", "B", "C"], ["B", "A", "D", "E"], ["C", "F", "A"]] returns [["A", "B", "C"], ["D", "E", "B", "A"], ["C", "F", "A"]].
  • [["A", "B"], ["B", "A", "C"]] returns [["A", "B"], ["C"]], because after C every title is on the screen.

The follow-ups that candidate reports are a different width for each row, and special rows that skip the dedup (1 report). The phone screen put the rule another way: no row and no column of the first screen may repeat a show (1 report). Read literally, that lets a title appear twice on the screen, in different rows and different columns. The last level asks for that rule.

You don't write it yet. The lesson starts with the set that remembers what the screen shows, then fills one row, then the page, then the grid. At the end you solve the whole problem, level by level, in an interview simulation with a 45-minute timer.

This lesson builds on the seen-set from the hash maps lesson. It pairs with the billboard rotation: both decide what a Netflix viewer sees first.