Dsa
Queue
Medium
Coffee Shop Order Management
You are developing a system for a coffee shop to manage customer orders based on their priority. The orders may be of different priority levels (high or low). Implement a program that processes the orders using the following input format:
Input:
- First line contains an integer n (1 ≤ n ≤ 1000), the number of orders.
- The next n lines contain either 'ORDER <priority> <order_id>' or 'SERVE'.
<priority> is 'H' for high and 'L' for low.
<order_id> is a unique identifier for the order.
Output:
- Print the order IDs of the served orders in the order they were served. If no orders exist when a SERVE command is encountered, print 'No orders to serve'.
Example:
Input:
5
ORDER H 101
ORDER L 102
SERVE
ORDER H 103
SERVE
Output:
101
103
Key concepts
queueprioritysimulation
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