Dsa
Queue
Medium
Emergency Response Queue
In a city, multiple emergency calls are made to the response center, and each call contains a severity level and a timestamp. The center must respond to the calls based on their severity, with higher severity calls being prioritized. If two calls have the same severity, the one that arrived first should be handled first.
Input Format:
- The first line contains an integer E (1 <= E <= 1000), the number of calls made.
- Each of the next E lines contains an integer S (severity level) and an integer T (timestamp).
Output Format:
- Print the order of calls based on the sequence they will be responded to.
Example:
Input:
4
1 10
3 5
2 7
3 2
Output:
3 2 1 4
Key concepts
queuepriority queueemergency services
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