leetcode486】的更多相关文章

Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a number, that number will not be available for the…
public class Solution { public bool PredictTheWinner(int[] nums) { // int n = nums.Length; // int[,] dp = new int[n, n]; // for (int i = 0; i < n; i++) { dp[i, i] = nums[i]; } // for (int len = 1; len < n; len++) // { // for (int i = 0; i < n - l…
思路: 博弈. 实现: class Solution { public: bool PredictTheWinner(vector<int>& nums) { ][]; int n = nums.size(); ; i < n; i++) dp[i][i] = nums[i]; ; i >= ; i--) { ; j < n; j++) { dp[i][j] = max(nums[i] - dp[i + ][j], nums[j] - dp[i][j - ]); }…