Description

You are given an integer array nums. Two players take turns picking from either end of the array. The player with more points wins. Return true if Player 1 can win (or tie). Both players play optimally.

Examples

Input:nums = [1,5,2]
Output:false
Explanation:

Player 2 wins with optimal play.

Input:nums = [1, 5, 2]
Output:false
Explanation:

Given nums = [1, 5, 2], the condition does not hold: Player 1 can win (or tie).

Input:nums = [1, 5, 233, 7]
Output:true
Explanation:

Given nums = [1, 5, 233, 7], the condition holds: Player 1 can win (or tie).

Constraints

  • 1 ≤ nums.length ≤ 20
  • 0 ≤ nums[i] ≤ 10^7

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!