= the maximum score difference the current player can achieve on subarray nums. Positive means current player wins on this subarray, negative means they lose. Base case: . Only one element left. Current player takes it, and the difference equals that value since opponent gets nothing from this subarray.
This is interval DP: we compute answers for smaller ranges first, then build up to larger ranges. Process subarrays of length , then , then , and so on. The final answer is .