Dsa
Queue
Medium
Priority Document Processing
You are tasked with processing documents for printing where each document has a priority level that determines the order in which it is processed. A document with a higher priority level is processed before a document with a lower priority level. Implement a function to process all documents in the correct order given the priorities.
Input:
The first line contains an integer N, the number of documents.
The following N lines each contain a document ID (string) and its priority (integer) separated by a space.
Output:
Print the document IDs in the order they are processed, one per line.
Example:
Input:
3
doc1 2
doc2 1
doc3 3
Output:
doc3
doc1
doc2
Key concepts
queueprioritysorting
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