Dynamic ProgrammingOverlapping subproblems, remembered
DP rests on two things: subproblems recur, and the best answer to the whole is built from best answers to the parts. Start with memoisation, learn to define a state, write the transition and pick an order — then work through the common state designs: knapsack, sequences, grids, intervals, bitmasks and trees.
Why learn Dynamic Programming
Where it shows upHow far apart are "teh" and "the"? Edit distance counts the fewest changes, and it is behind both input methods and "did you mean".
→ Lesson: Edit DistanceWhich lines are unchanged, which were added or removed — that is the longest common subsequence.
→ Lesson: LCSA fixed budget, each option with a cost and a payoff, and you want the best combination. That is the knapsack problem, and cloud capacity planning is the same question.
→ Lesson: 0/1 KnapsackNaive Fibonacci recomputes the same subproblem millions of times. Remember the answers and exponential time becomes linear — that is where DP starts.
→ Lesson: Memoization & Tabulation