Dsa
Queue
Medium
Job Scheduling with Priorities
You are given a list of jobs, each with a job ID and a priority (higher number indicates higher priority). You need to simulate scheduling these jobs in a way that higher priority jobs are processed first. If two jobs have the same priority, the job that arrived first should be processed first.
Input Format:
- The first line contains an integer N (1 <= N <= 1000), the number of jobs.
- The next N lines each contain an integer job_id and an integer priority.
Output Format:
- A single line output with the order of processed job IDs, separated by spaces.
Example:
Input:
4
1 2
2 1
3 3
4 2
Output:
3 1 4 2
Key concepts
queuepriorityscheduling
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