0PricingLogin
Competitive Programming Academy · Lesson

Memoization vs Tabulation

Two ways to cache subproblem answers.

Why Cache at All

Naive recursion redoes the same work again and again. Dynamic programming stores each answer once so you never recompute it.

fib(40)  # slow: recomputes endlessly

Overlapping Subproblems

DP applies when a problem splits into overlapping subproblems. The same smaller case shows up across many branches of the recursion.

fib(5) needs fib(3) twice

All lessons in this course

  1. Memoization vs Tabulation
  2. Define State and Transition
  3. Climbing Stairs & Coin Combinations
  4. Longest Increasing Subsequence
← Back to Competitive Programming Academy