Dynamic Programming21 sections · 916 units
Open in Course

LeetCode 312 Burst Balloons - State Definition

Open intervals

Define dp[i][j]dp[i][j] = max coins from bursting all balloons strictly between i and j (exclusive). We add virtual balloons with value 11 at positions 00 and n+11.

Base case: dp[i][i+1]dp[i][i+1] = 00. No balloons between adjacent positions. Goal: dp[0][n+1]dp[0][n+1], the max coins from bursting all balloons between the virtual boundaries. Choosing what dp[i][j] represents is often the hardest part. It must capture everything needed to solve that range on its own.