Question bank › Greedy
Dsa Greedy Hard

Segment Selection for Maximum Benefit

In a software development project, several segments of time can be allocated to different tasks. Each task can only occupy a segment of time, and overlapping allocations should be avoided. Given the start and end times of multiple tasks, determine the maximum number of tasks that can be allocated without overlap. Input Format: - The first line contains an integer N (1 <= N <= 1000), the number of tasks. - The following N lines each contain two integers: start time and end time of the tasks (0 <= start < end <= 10000). Output Format: - Print a single integer representing the maximum number of non-overlapping tasks that can be scheduled. Example: Input: 3 1 3 2 4 3 5 Output: 2 In this example, you can select tasks (1,3) and (3,5) for maximum allocation without conflict.

Key concepts

greedyintervalsoverlapping

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.