Two players, Alice and Bob, play a game using an integer array nums.
• Alice and Bob take turns, with Alice starting first.
• On each turn, a player must choose one number from either end of the array — that is, nums[0] or nums[n - 1].
• The chosen number is added to the player’s total score, and that number is removed from the array.
• The game continues until no numbers remain in the array.
Both players play optimally, trying to maximize their final score.
Return true if Alice (Player 1) can win or tie, otherwise return false.
Input: nums = [2, 9, 1]
Output: false
Input: nums = [4, 10, 6, 12]
Output: true
Accepted:
Submission: