Greedy Algorithms8 sections · 316 units
Open in Course

Problem - Activity Selection

The classic setup

You are given nn activities. Each activity ii has a start time sis_i and an end time eie_i. Two activities conflict if their time intervals overlap. Goal: Select the maximum number of non-overlapping activities.

Example: activities = [(1,4), (3,5), (0,6), (5,7), (8,9), (5,9)]. Which activities should you select? Before reading on, try to find the answer yourself. This problem appears in scheduling, resource allocation, and interval problems. The brute force approach of trying all subsets takes 2n2^n time, which is too slow.