Description
There are n coins in a line. Two players take turns to take a coin from one of the ends of the line until there are no more coins left. The player with the larger amount of money wins.
Could you please decide the first player will win or lose?
Example
Given array A = [3,2,2], return true.
Given array A = [1,2,4], return true.
Given array A = [1,20,4], return false.
Solution
在i-j区间能取的最大值为:i-j区间元素的总和-对手在剩下区间能取到的元素的总和的较小值。状态方程为dp[i][j] = sum[i][j] - min(dp[i+1][j], dp[i][j-1])