Question bank › Queue
Dsa Queue Warm-up

Print First N Elements from a Queue

Implement a queue data structure with a method to print the first N elements in the queue. The queue will accept integers and will support the operations of enqueue (adding an integer to the back) and print (printing the first N integers). Read input as the number of enqueue operations followed by the numbers to enqueue, a command to print the first N elements, and then the value of N. If N is larger than the number of elements in the queue, print all elements. Example: Input: 5 1 2 3 4 5 print 3 Output: 1 2 3

Key concepts

queuebasic operationsiteration

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.