Question bank › Heap
Dsa Heap Hard

High Priority Task Scheduler

You are building a task scheduler that schedules tasks based on their priority and estimated execution time. Each task has a priority (higher is more important) and an execution time. Given a list of tasks, you need to output the order of task execution based on priority first, and by execution time second if priorities are the same. Input Format: The first line contains an integer n (1 <= n <= 10^5), the number of tasks. The next n lines contain two integers p (1 <= p <= 100) and t (1 <= t <= 100), representing the priority and estimated execution time of each task. Output Format: Output the order of task indices (1-based) for execution. Example: Input: 3 5 3 2 4 5 1 Output: 1 3 2

Key concepts

heappriority_queuescheduling

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.