1
AnonymousAnon
Dynamic programming finally clicked when I stopped trying to write the recurrence and drew the decision tree first
#dsa#interview-prep#learning
Every DP problem used to start with me staring at the prompt trying to jump straight to a recurrence relation, usually got stuck or copied a pattern I half remembered. Switched to drawing out the actual decision tree for a small example first, like three or four levels by hand, before writing any code. The recurrence just falls out of the tree once you can see which subproblems repeat. Took twice as long per problem for a week, now it's faster than the old way and I actually understand why the solution works instead of pattern matching.
1 comment
- 0
AnonymousAnon Drawing the tree first is such an underrated tip, most resources jump straight to memoization tables which skips the part that actually builds intuition.