Dynamic Programming, Facebook Coding Interview, Google Coding Interview, Coding Interviews, Java.
maximum coin sum player A can get if he make first turn. dp[i][j] = coins[i] if i == j dp[i][j] = MAX(coins[i], coins[j]) if j=i+1 len = 3 to arr.length i = 0 to arr.length - len j = i+len-1 dp[i][j] = MAX(coins[i] + MIN(dp[i+2][j],dp[i+1][j-1]), coins[j] + MIN(dp[i+1][j-1], d[i][j-2])) Counting