Game DP — Filling the Score-Difference Table

dp[i][j] = max( a[i] − dp[i+1][j], a[j] − dp[i][j−1] ) is the best score difference the player to move can force on coins a[i..j]. Watch the interval table fill by increasing length.

step 0

Coins a[i..j]

Press Step to fill the first cell. Each cell asks: take the left coin or the right coin?
Final answer appears here once the table is full.
base dp[i][i]=a[i] dependency cell current dp[i][j]

dp[i][j] interval table

rows = i (left index), cols = j (right index); only i ≤ j is used.
We fill by increasing interval length: first all single coins (the base case), then pairs, then triples, up to the whole row. dp[0][n−1] ≥ 0 means player 1 wins or ties.
Self-contained visualization. Zero-sum, perfect-information pick-from-ends game; dp stores the score difference (player-to-move minus opponent), not raw scores. Recover raw scores via (totalSum ± dp[0][n−1]) / 2. See junior.md and professional.md for the proof that the subtraction encodes optimal adversarial play.