Question bank › Queue
Dsa Queue Warm-up

Queue of Songs

You are building a music player that operates with a queue of songs. Each song is represented by its title (a string). Your task is to implement the functionality of adding songs to the queue and playing the song at the front of the queue. You will read requests from the input, which can be either 'add <song_title>' to add a song to the queue or 'play' to play the current song and remove it from the queue. If the queue is empty when a 'play' request is made, print 'No songs in the queue.'. Input format: - The first line contains an integer n (1 <= n <= 100) indicating the number of requests. - The next n lines contain the requests as described above. Output format: - Print the result of play requests or song added confirmations. Example: Input: 4 add Song1 add Song2 play play Output: Song added: Song1 Song added: Song2 Playing: Song1 Playing: Song2

Key concepts

queuestringlist

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.