Activity Selection
Learn Activity Selection (Greedy Algorithms, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Selecting the Maximum Number of Non-Overlapping Activities Given activities each with a start and end time, pick the MAXIMUM number that don't overlap. The greedy insight: always pick the activity that FINISHES EARLIEST among the remaining valid options - it leaves the most room for future activities. Sort by end time, then scan once.