What interviewers ask next
The candidates report two follow-ups after the code (2 reports):
- Multithreading. One candidate answered by saying out loud where the locks would go, and that part went fine (1 report).
- Running it in production. How you'd scale it, and how you'd store and read the data (1 report).
Other natural ones are many viewers sharing one ranking, and what you'd test.
Where the locks go
get and update both read and change the two lists. Run them on two threads at once and an update can delete a key while get is moving it between lists, or both can pop the same key. So each whole call needs the lock, from the first read to the last write.
One lock for the billboard is the right first answer. A lock per list sounds finer, and it breaks: get changes both lists in one step, so it would need both locks, and two calls that take them in opposite orders can wait on each other forever. Say that, then say what you'd measure before splitting the lock: how long a call holds it. At about 20 µs per update, one lock serves tens of thousands of calls a second.
Use with self.lock:. It gives the lock back when the block ends, even when the call inside raises. An acquire and release pair without try and finally leaves the lock held after an error, and every later call waits forever.
The editor holds LockedBoard, which wraps any billboard, and OneTitle, a stand-in board that always shows Comet. Write get and update in LockedBoard so each runs inside self.lock.