Question bank › Sorting
Dsa Sorting Hard

Project Deadline Scheduling

You are a project manager and need to schedule your team’s tasks based on their deadlines and the time required to complete them. Each task has a deadline and a duration. Your goal is to sort the tasks such that the tasks with the earliest deadline come first, and among tasks with the same deadline, the one with shorter duration comes first. Input: The first line contains an integer n (1 ≤ n ≤ 1000), the number of tasks. The next n lines each contain two integers, d (1 ≤ d ≤ 1000) and t (1 ≤ t ≤ 1000), representing the deadline and time required to complete the task. Output: Print the sorted list of tasks in the format 'Deadline: Duration'. Example: Input: 3 2 2 1 1 2 1 Output: 1: 1 2: 1 2: 2

Key concepts

sortingprioritygreedy

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.