- 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
packagecom.fishercoder.solutions.fourththousand;
publicclass_3232 {
publicstaticclassSolution1 {
publicbooleancanAliceWin(int[] nums) {
intaliceScore = 0;
intbobScore = 0;
// alice single digit, bob double digits
for (intnum : nums) {
if (num > 9) {
bobScore += num;
} else {
aliceScore += num;
}
}
if (aliceScore > bobScore) {
returntrue;
}
// now alice double, bob the rest
aliceScore = 0;
bobScore = 0;
for (intnum : nums) {
if (num > 9) {
aliceScore += num;
} else {
bobScore += num;
}
}
if (aliceScore > bobScore) {
returntrue;
}
returnfalse;
}
}
}