Question bank › Greedy
Dsa Greedy Medium

Scheduling Tasks with Deadlines

You are given a list of tasks, each represented by a tuple (duration, deadline). Your goal is to schedule these tasks in such a way that you maximize the number of completed tasks before their respective deadlines. Write a function that takes a list of tasks and returns the maximum number of tasks that can be completed on time. Input: The first line contains an integer `n` (1 ≤ n ≤ 100), the number of tasks. The second line contains `n` pairs of integers, where each pair consists of two integers representing the duration and the deadline of each task. Output: Return the maximum number of tasks that can be completed on time. Example: Input: 4 2 3 1 2 2 4 1 1 Output: 3 In this example, you can complete tasks (1, 2), (2, 3), and (2, 4) in the available time slots.

Key concepts

greedysortingintervals

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.