PATTERN 16: Interval DP / Partition DP (Choose-the-Split Thinking)

D

Qubits of DPK

April 11, 2026

Core DSA

Core Idea (lock this)

“The answer for a range depends on
You are not moving pointers.
You are trying every possible partition point and choosing the best.
If greedy asks “what’s best now?”,
Interval DP asks “what’s the best split?”

How to Recognize This Pattern (CRITICAL)

You should instantly think Interval / Partition DP when:
  • The problem involves:
  • You see:
  • The operation:
  • You hear:
Trigger phrases:
  • “partition”
  • “split”
  • “burst”
  • “merge”
  • “cut”

30 MUST-DO INTERVIEW PROBLEMS

(10 Easy → 10 Medium → 10 Hard)

EASY (Intro to Range Thinking)

Goal: understand why brute force explodes.
  1. #
    Matrix Chain Multiplication (Basic recursion idea) — GFG
  2. #
    Minimum Score Triangulation of Polygon — LC 1039
  3. #
    Guess Number Higher or Lower II — LC 375
  4. #
    Stone Game (basic DP view) — LC 877
  5. #
    Optimal Strategy for a Game — GFG
  6. #
    Boolean Parenthesization (Intro) — GFG
  7. #
    Minimum Cost Tree From Leaf Values — LC 1130
  8. #
    Palindrome Removal — LC 1246
  9. #
    Stone Game II — LC 1140
  10. #
    Zuma Game — LC 488
Now EASY builds:
  • Split index iteration
  • Two-player interval logic
  • Partition-based recursion
  • Combining left + right

️ MEDIUM (True Interval DP)

Now we define dp[l][r] formally.
  1. #
    Matrix Chain Multiplication (Tabulation) — GFG
  2. #
    Palindrome Partitioning II — LC 132
  3. #
    Burst Balloons — LC 312
  4. #
    Minimum Cost to Cut a Stick — LC 1547
  5. #
    Strange Printer — LC 664
  6. #
    Remove Boxes — LC 546
  7. #
    Stone Game III — LC 1406
  8. #
    Interleaving String (range-style view) — LC 97
  9. #
    Longest Palindromic Subsequence — LC 516
  10. #
    Count Different Palindromic Subsequences — LC 730
This section locks:
  • dp[l][r] formulation
  • Reverse iteration filling
  • Multi-branch split
  • State compression challenges

HARD (Advanced Split & Optimization)

Now it gets serious.
  1. #
    Minimum Cost to Merge Stones — LC 1000
  2. #
    Egg Dropping Problem — LC 887
  3. #
    Remove Boxes (Optimized 3D DP) — LC 546
  4. #
    Strange Printer II — LC 1591
  5. #
    Burst Balloons (Optimized Thinking) — LC 312
  6. #
    Maximum Score from Performing Multiplication Operations — LC 1770
  7. #
    Predict the Winner — LC 486
  8. #
    Partition Array for Maximum Sum – LC 1043
  9. #
    Make Array Strictly Increasing – LC 1187
  10. #
    Optimal Binary Search Tree – GFG
Now HARD demands:
  • 2D/3D DP
  • Non-trivial transitions
  • Split + additional state
  • Optimization beyond naive O(n³)

Pattern 16 is now LOCKED

The ONE Rule That Wins Interviews

Always be able to answer:
“What does
If you can’t define that cleanly,
the DP will collapse.

Common Interview Mistakes

  • Forgetting base cases (l > r, l == r)
  • Double-counting partitions
  • Writing recursion without memoization
  • Not explaining why splitting works

INTERVIEW REVISION CARD — Pattern 16

1️⃣ Pattern in One Line

"The answer for a range depends on WHERE you split it — try every possible partition point and pick the best."

2️⃣ Recognize It When...

  • Problem involves ranges, intervals, or subarrays
  • Trigger words: "partition", "split", "burst", "merge", "cut", "minimum cost over range"
  • Operation combines left + right results
  • "Try all possible ways" phrasing

3️⃣ Don't Confuse With...

  • Regular DP (P13) → 1D DP on elements; Interval DP on ranges [l, r]
  • Greedy (P9) → greedy commits to one split; interval DP tries ALL splits
  • Divide & Conquer → D&C splits once; interval DP tries every split point

4️⃣ Approach in 3 Steps

  1. #
    Define dp[l][r] = best answer for subarray/range [l, r]
  2. #
    Try every split point k: dp[l][r] = best over all k in [l, r-1]
  3. #
    Fill in order of increasing length (small ranges first)

5️⃣ Invariant to Maintain

"dp[l][r] always contains the optimal answer for the range [l, r] — smaller ranges are always computed before larger ones."

6️⃣ Complexity to Justify

  • Time: O(N³) — N² states × N split points
  • Space: O(N²) — 2D DP table
  • Why: Every subrange tried for every split point

7️⃣ Edge Cases to Always Check

  • Base case: dp[i][i] = 0 or single element value
  • l > r — invalid range, return 0 or infinity
  • Length 2 ranges — simplest non-trivial case
  • Modular arithmetic if answer is large
  • Fill order: length 1 → length 2 → ... → length N

8️⃣ One Line to Say in Interview

"This is interval DP — dp[l][r] represents the optimal answer for range [l,r], computed by trying every split point k in O(N³) time."