← 返回 waymo 的题目列表Predict the Winner
类型:online_judge
Problem: Predict the Winner
Given an integer array nums, representing a row of scores/stones. Two players take turns picking one number from either end of the array and add it to their own score. Player 1 moves first, and both players play optimally.
Determine whether Player 1 can finish the game with a score greater than or equal to Player 2's score. If yes, print true; otherwise, print false.
Input Format
The first line contains an integer n, the length of the array.
The second line contains n integers, representing nums.
Output Format
Print one line: true or false.
Constraints
1 <= n <= 20
0 <= nums[i] <= 10^7
Example 1
Input:
3
1 5 2
Output:
false
Explanation: Whether Player 1 picks 1 or 2, Player 2 can pick 5, so Player 1 loses.
Example 2
Input:
4
1 5 233 7
Output:
true
Example
Input
3
1 5 2
Output
false