0PricingLogin
Competitive Programming Academy · Lesson

Define State and Transition

Name what dp[i] means precisely.

The Heart of DP

Every DP starts by naming a state: what does dp[i] actually represent? Get this sentence right and the rest follows.

State Must Be Precise

Write the meaning in words: dp[i] = the answer for the first i items. A fuzzy state definition leads to a buggy recurrence.

dp[i] = best total using items 0..i-1

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