题目:
题解:
class Solution:def PredictTheWinner(self, nums: List[int]) -> bool:length = len(nums)dp = [0] * lengthfor i, num in enumerate(nums):dp[i] = numfor i in range(length - 2, -1, -1):for j in range(i + 1, length):dp[j] = max(nums[i] - dp[j], nums[j] - dp[j - 1])return dp[length - 1] >= 0