AlgoPlus//structures / greedy
Read the theory

Greedy · Activity Selection

Sort by finish time, then keep every activity that doesn't overlap the last pick.

Activities
7
Selected
0
Your activities (start-end, comma-separated)
Legend
Selected
Considering
Activity
AI Tutor Workspace
In a nutshell
A greedy algorithm builds its answer by always taking the choice that looks best right now and never going back to revise it. That only reaches the true best answer for special problems — activity selection is one: sort the activities by when they finish, then keep grabbing the earliest-ending one that doesn't overlap your last pick, and you fit the most activities possible.
Ready
Press play to begin the cinematic walkthrough.
Make the locally optimal choice at each step and never reconsider. For the right problems (like activity selection) that local greed is provably globally optimal.
Key terms
Go deeper in the lesson
Read the full theory, intuition & complexity for Greedy · Activity Selection.