Visualize the greedy Activity Selection algorithm step by step. Watch how sorting by finish time and greedily picking non-overlapping activities maximizes the count.
Sort all activities by finish time. Always pick the activity that finishes earliest, because it leaves the most time for the remaining activities.
For each activity (in finish-time order), check if its start ≥ last selected activity's finish. If yes → select it. If no → skip (it overlaps).
The activity finishing earliest can always be exchanged for the first activity in any optimal solution without reducing the count. This "greedy exchange" argument proves optimality.
O(N log N) to sort + O(N) to scan = O(N log N) overall. Space O(N) for the output.