piles of stones. Two players take turns removing a pile from either end. Find the largest your score. = max score difference (my score. Opponent's) for piles .
Positive means I win. Transition: . Take left or right, subtract opponent's best. The subtraction handles alternating turns. If , first player wins. This is a classic game theory problem that can be solved with interval DP. The state captures optimal play.