Question bank › Greedy
Dsa Greedy Medium

Activity Selection Problem

Given a set of activities with start and end times, your goal is to select the maximum number of activities that don't overlap. Each activity is represented by a pair of integers (start, end). An activity is considered to be finished if it ends before another begins. Input format: - The first line contains an integer N (1 ≤ N ≤ 1000), the number of activities. - The next N lines contain two integers each, representing the start and end time of each activity. Output format: - Print a single integer representing the maximum number of non-overlapping activities. Example: Input: 5 1 3 2 5 4 6 5 7 8 9 Output: 4

Key concepts

greedyschedulingsorting

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.