Dynamic Programming
note
all DP problems can be converted into
Direct Acyclic Graph
(DAG
)- then we can solve them simply as we solve DAG problems
some common graph problems can also be converted to DAG
Commom Way to Solve DP​
- solve using Memoization
- if needed then convert memoization to Tablulation
- if need to Print Optimal Solution i. do it with memoization ii. or with table formed in Tablulation
My way to solve DP problems​
- Convert a DP prblem to DAG graph
- Topologicaly sort that DAG
- choose the
top
element of the Topologically sortedstack
& then use it & after that justpop
it - Now use the different logic for getting the Optimal Solution like min,max,count