Practice Discrete Math

Algorithms / Interval Dp

Least You Need to Know: Interval DP, Length Order, and Split-Point Recurrences

Interval DP appears when the answer for a segment depends on smaller subsegments inside it. The recurring choices are the interval state, the base case for tiny segments, and the split point or last action that combines two smaller answers into the larger one.

The least you need to know

Key notation

dp[l][r] best answer for the interval from `l` to `r`
length = r-l+1 order in which states are often filled
k split point or last action inside the interval

Tiny worked example

  • In matrix-chain multiplication, `dp[l][r]` is the minimum cost to multiply matrices from `l` to `r`.
  • The recurrence tries every split point `k`, combining the left interval, the right interval, and the cost of joining them.
  • Because those smaller intervals are shorter, filling by length works naturally.

Common mistakes

How to recognize this kind of problem

Start practice