##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
You've seen range-based DP. Here you solve Matrix Chain Multiplication and Burst Balloons, where you split intervals and combine subproblem answers.
Merge, split, combine
When subproblems nest inside
CF 607B - remove palindromes
Same endpoints merge free
dp[l][r] = moves to clear
Match ends, split, or single
Empty = 0, single = 1
Bottom-up by length
O(n³) with O(n²) states
LC 1000 - merge k at a time
When is one pile possible?
Piles mod (k-1) matters
Step by k-1 in splits
Prefix sums for merge cost
CF 149D - color matched brackets
Matching structure guides DP
4D state: positions and colors
Inside first, then combine
Stack finds the pairs
LC 1039 - triangulate polygon
One triangle per edge
dp[l][r] for vertex range
Try each apex vertex k
O(n³) for n vertices
LC 1547 - cutting costs
Add 0 and n as boundaries
LC 664 - overwriting printer
Extend matching chars free
LC 546 - group same colors
3D: track trailing boxes
What makes interval DP?
Empty ranges, single elements
Length order, not index order
LC 471
Solution approach
LC 1246
Solution approach
From MCM to Remove Boxes