Algorithm visualizer
Pick an algorithm, enter your own numbers or use a preset, then step through the run. The pseudocode and the explanation follow each step.
Sort by end time and always take the interval that finishes first among those that fit. That choice never blocks a better one later.
Add an interval that ends earliest but starts earliest too. Does greedy still take the same count?
Step 1 of 18
Sort the intervals by end time, earliest first. The row below each end shows its start.