Algorithms / 2 visualizations
Greedy Algorithm Visualizers
Take the best-looking move now, and know when that is provably right.
Open the lab → Every one runs on your own input, step by step, with the code highlighted in Java, Python, C++, C or JavaScript. Free, no sign-up.
All greedy visualizations
- Jump GameO(n)
Walk left to right and keep far, the furthest index reachable so far. If you ever stand on an index beyond far, you are stuck. If far reaches the end, you win.
- Interval Scheduling (Non-Overlapping)O(n log n)
Sort by end time. Keep an interval if it starts at or after the end of the last one kept. Finishing as early as possible leaves the most room for everything after.