Amazon Coding Interview Question: Amazon Music Playlist Manager | Queue Data Structure

19 Views
No Comments

Let’s create a music playlist manager for Amazon Music, which allows users to:

  • add songs to the playlist
  • play a song from the playlist in order

Implement the methods for adding and playing songs.

If the user wants to add another song while the playlist is full, the oldest-added song needs to be removed first.

This problem asks you to build a playlist manager that supports adding songs and playing them in insertion order. The key requirement is FIFO behavior: when the playlist is full, the oldest-added song must be removed before inserting a new one. A queue-like data structure is the natural fit for implementing efficient <code>add</code> and <code>play</code> operations.

END
 0