- Tutorials
- DSA Tutorial
- Greedy
Greedy
2 lessonsAbout 12 minutesAdvanced
This part of the DSA Tutorial runs from Greedy Algorithms Explained through to Greedy vs Dynamic Programming. There are 2 lessons here, and working through them takes about 12 minutes at a steady pace.
It follows on from Dynamic Programming, so finish that first if you have not already — the examples below assume you are comfortable with it.
Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.
- 1Greedy Algorithms ExplainedA greedy algorithm takes the best option at every step and never reconsiders. Learn when that gives the right answer, when it silently does not, and how to tell the difference.
- 2Greedy vs Dynamic ProgrammingGreedy commits to one choice; dynamic programming tries all of them. Learn how to decide which a problem needs, with the same problem solved both ways in JavaScript.
