Concept Flow - Greedy vs DP How to Know Which to Apply
Start Problem
Check Problem Structure
Is problem optimal substructure?
No→Greedy Not Suitable
Yes
Is problem overlapping subproblems?
No→Use Greedy
Yes
Use Dynamic Programming
Implement Solution
End
Start by checking if the problem has optimal substructure. If yes, check for overlapping subproblems. If overlapping exists, use DP; otherwise, greedy.
