juniorDynamic Programming
Difference between Greedy and DP?
Updated Apr 28, 2026
Short answer
Greedy makes the best local choice; DP considers all subproblems to find the global optimum.
Deep explanation
Dynamic Programming (DP) is an algorithmic paradigm that solves a given complex problem by breaking it into subproblems and stores the results of subproblems to avoid computing the same results again. Greedy makes the best local choice; DP considers all subproblems to find the global optimum.
Real-world example
Cashiers giving change using the minimum number of coins.
Common mistakes
- Creating a memoization table but forgetting to check it before recursing.
Follow-up questions
- What is the space complexity of this Fibonacci approach?