DP on Subarrays
DP on Subarrays
What this pattern is
DP on subarrays (also called interval DP / range DP) is used when the answer for a segment can be computed from answers of smaller segments inside it. A very typical state is:
- = answer for subarray (or substring) from to .
This shows up when you “build” a segment by splitting it into two smaller parts, or when you expand from shorter intervals to longer ones.
Standard DP template
State
Define for .