Question bank › Queue
Dsa Queue Medium

Order Processing

You are responsible for processing customer orders at a café. Orders arrive in a sequence, and each order has a priority based on the type of drink. High-priority drinks must be served before lower-priority drinks, regardless of their arrival time. Your task is to determine the order in which drinks will be served. The input consists of an integer n followed by n lines, each containing a string representing the drink type and its priority level (an integer). The output must list the drinks in the order they will be served. An order with higher priority (lower number) is served before ones with lower priority (higher number). For drinks with the same priority, they are served in the order they arrive. Example Input: 5 Coffee 1 Tea 2 Juice 1 Water 3 Soda 2 Example Output: Coffee Juice Tea Soda Water

Key concepts

queuesimulationprocessing

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.