```
public boolean PredictTheWinner(int[] nums) {
if (nums == null || nums.length == 0) return true;
int n = nums.length;
int[] scores = new int[n+1];
for (int len = 0; len < n; len++) {
for (int i = 0; i+len < n; i++) {
scores[i] = Math.max(nums[i] - scores[i+1], nums[i+len] - scores[i]);
}
}
return scores[0] >= 0;
}
```