FastPrepMusic Player Operation Sequence
Problems/Music Player Operation Sequence

Music Player Operation Sequence

Atlassian logoAtlassian● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report asks for an object-oriented music player with play, pause, next, queue, loop, and shuffle behavior. This finite operation adapter supplies deterministic shuffle and serialized state after each command.

Simulate a music player over a finite ordered command sequence. initialQueue[0] is initially selected, the remaining tracks wait in order, and playback starts paused.

  • PLAY and PAUSE change the playback state when a track is selected.
  • NEXT advances to the first waiting track. With looping enabled, the previous current track moves to the end of the waiting queue; otherwise it is discarded. If no track remains, the player becomes paused with current track NONE.
  • LOOP_ON and LOOP_OFF change the loop setting.
  • SHUFFLE:seed reorders only the waiting queue with Fisher-Yates. Starting with state = seed, for i from the last index down to 1, set state = (state * 1103515245 + 12345) mod 2^31 and swap positions i and state mod (i + 1).

After every command, return current|PLAYING_OR_PAUSED|comma-separated-waiting-queue.

Function

simulatePlayer(initialQueue: String[], operations: String[]) → String[]

Examples

Example 1

initialQueue = ["A","B","C"]operations = ["PLAY","NEXT","LOOP_ON","NEXT"]return = ["A|PLAYING|B,C","B|PLAYING|C","B|PLAYING|C","C|PLAYING|B"]

The first NEXT discards A. After looping is enabled, advancing from B moves B to the back.

Example 2

initialQueue = ["A","B","C","D"]operations = ["SHUFFLE:1","NEXT","PAUSE"]return = ["A|PAUSED|D,C,B","D|PAUSED|C,B","D|PAUSED|C,B"]

The deterministic shuffle reorders only B, C, and D. NEXT selects D without changing the paused state.

Constraints

  • 1 <= initialQueue.length <= 5000.
  • 1 <= operations.length <= 5000.
  • Track names are nonempty, unique, printable ASCII strings without | or commas.
  • Every command is one of the documented forms.
  • 0 <= seed < 2^31.

More Atlassian problems

  • Deterministic Word Guess SolverONSITE INTERVIEW · Seen Oct 2026
  • Generate Word Guess FeedbackONSITE INTERVIEW · Seen Oct 2026
  • Bounded Word Guess SolverONSITE INTERVIEW · Seen Oct 2026
All Atlassian interview questionsSee Atlassian hiring insights
Saved
public String[] simulatePlayer(String[] initialQueue, String[] operations) {
    // Write your code here.
}
Checking account…