Glossary: Algorithms Beyond the Basics in JavaScript
Overlapping subproblems
The same smaller question being asked many times inside a bigger problem. Plain recursion for `ways(30)` re-asks `ways(28)` over and over, which is what makes it slow.
Glossary: Algorithms Beyond the Basics in JavaScript
The same smaller question being asked many times inside a bigger problem. Plain recursion for `ways(30)` re-asks `ways(28)` over and over, which is what makes it slow.