FastPrepMovie Billboard Rotation
Problems/Movie Billboard Rotation

Movie Billboard Rotation

Netflix logoNetflix● MediumFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The source identifies movie billboard rotation, a two-ordered-map approach, and concurrency and storage follow-ups, but omits the exact lifecycle and rotation rules. The judged core task matches the visible source at about 80%.

Process an ordered sequence of operations for a movie billboard. The billboard keeps an active rotation of movie IDs.

  • ["ADD", movieId]: if movieId is inactive, append it to the tail of the rotation and assign it a new monotonically increasing position. Adding an active ID is a no-op.
  • ["REMOVE", movieId]: remove the active movie. Removing a missing ID is a no-op. A later successful re-add receives a new tail position; old positions are never reused.
  • ["NEXT"]: return the active successor after the last displayed position. The first non-empty call returns the active head, and traversal wraps to the head after the tail. If no movie is active, return NONE without moving the cursor.

Only NEXT contributes an element to the returned array, in operation order.

Do not use a heap. Model the active rotation with an ordered position-to-movie map and a movie-to-position map. Multithreading, distributed scaling, and durable storage are follow-up discussion topics and are outside the judged single-threaded core.

Function

rotateBillboard(operations: String[][]) → String[]

Examples

Example 1

operations = [["ADD","A"],["ADD","B"],["ADD","C"],["NEXT"],["NEXT"],["REMOVE","B"],["NEXT"],["ADD","B"],["NEXT"],["NEXT"]]return = ["A","B","C","B","A"]

The first two calls display A and B. Removing B leaves the cursor at its old position, so the next successor is C. Re-adding B places it after C, then the rotation wraps to A.

Example 2

operations = [["NEXT"],["ADD","x"],["ADD","x"],["NEXT"],["REMOVE","missing"],["NEXT"],["REMOVE","x"],["NEXT"],["ADD","x"],["NEXT"]]return = ["NONE","x","x","NONE","x"]

An empty rotation returns NONE. Duplicate ADD and missing REMOVE operations do nothing. After removal, re-adding x creates a new active tail entry.

Example 3

operations = [["ADD","a"],["ADD","b"],["ADD","c"],["ADD","d"],["NEXT"],["REMOVE","b"],["REMOVE","c"],["NEXT"],["REMOVE","d"],["NEXT"],["ADD","c"],["NEXT"]]return = ["a","d","a","c"]

Deleted positions are skipped. After d is removed, the next active position wraps to a. Re-added c receives a new tail position and is the next successor.

Constraints

  • 1 <= operations.length <= 10^5.
  • Each operation is exactly ADD, REMOVE, or NEXT with the stated arity.
  • Each movie ID contains between 1 and 64 printable ASCII characters and is not NONE.
  • The operation sequence is evaluated by one thread.

More Netflix problems

  • Timed Cache with Sidecar CleanupPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Repeated Titles in Viewing HistoryPHONE SCREEN · Seen Sep 2026
  • Score-Rotating Movie PlaylistONSITE INTERVIEW · Seen Sep 2026
All Netflix interview questionsSee Netflix hiring insights
Saved
class Solution {
    public String[] rotateBillboard(String[][] operations) {
      // write your code here
    }
}
Checking account…