-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_3232.java
35 lines (34 loc) · 982 Bytes
/
_3232.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.fishercoder.solutions.fourththousand;
public class _3232 {
public static class Solution1 {
public boolean canAliceWin(int[] nums) {
int aliceScore = 0;
int bobScore = 0;
// alice single digit, bob double digits
for (int num : nums) {
if (num > 9) {
bobScore += num;
} else {
aliceScore += num;
}
}
if (aliceScore > bobScore) {
return true;
}
// now alice double, bob the rest
aliceScore = 0;
bobScore = 0;
for (int num : nums) {
if (num > 9) {
aliceScore += num;
} else {
bobScore += num;
}
}
if (aliceScore > bobScore) {
return true;
}
return false;
}
}
}