Music Player Operation Sequence
Reported by candidates from Atlassian's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Atlassian OA, reported September 2026, is getting the NEXT and SHUFFLE details slightly wrong and never noticing. It's a Music Player Operation Sequence problem, and it's pure simulation over arrays. You track a current track, a playing flag, a loop flag and a waiting queue, then emit a formatted string after every command. Nothing is hard algorithmically, but one off-by-one in the shuffle breaks every later line. If you blank mid-assessment, StealthCoder runs invisibly on your desktop as a safety net and gives you the solution in real time.
The problem
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.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is discipline, not cleverness. Keep a current track (or NONE), a playing boolean, a loop boolean and a queue. NEXT: if looping, push the old current to the queue's end, then pop the front as the new current. If nothing remains, set current to NONE and pause. Watch the order: with looping on and an empty queue, the old track goes to the back first and then gets selected again. Shuffle is Fisher-Yates over the waiting queue only, never the current track. Loop i from the last index down to 1, update state with the LCG, mod 2^31, then swap i and state mod (i+1). Use 64-bit math so state times 1103515245 doesn't overflow. With 5000 operations on 5000 tracks, O(n) per command is fine, but use a deque for NEXT. If the shuffle trips you in the live OA, StealthCoder is the hedge that catches it.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Music Player Operation Sequence cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Atlassian's OA.
Atlassian reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Music Player Operation Sequence FAQ
How hard is the Atlassian Music Player Operation Sequence problem really?+
Easy on algorithms, medium on care. There's no clever data structure. The difficulty is following the spec exactly: NEXT with looping, empty queues, paused state preserved, and the shuffle formula. Most failures are small ordering bugs, not missing insight.
What's the trick to the SHUFFLE command?+
Run Fisher-Yates on the waiting queue only. Start with state equal to the seed. For i from the last index down to 1, update state with state * 1103515245 + 12345 mod 2^31, then swap positions i and state mod (i+1). Use 64-bit integers so the multiply doesn't overflow.
What happens when NEXT is called and the queue is empty?+
With looping off, the current track is discarded and nothing remains, so current becomes NONE and playback pauses. With looping on, the old current goes to the end of the queue first, so it gets selected again. Handle that order explicitly.
Do PLAY and PAUSE work when no track is selected?+
The spec says they change state only when a track is selected. So if current is NONE, ignore them and stay paused. Check this before flipping the flag, and still output a line after the command.
How do I prepare for this in 48 hours?+
Write a small simulation by hand and trace Example 1 and Example 2 line by line. Then test edge cases: single track, loop on with an empty queue, shuffle with one waiting track, and NEXT past the end. Simulation problems reward careful tracing over volume of practice.