forked from doocs/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.java
30 lines (30 loc) · 892 Bytes
/
Solution.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
class Solution {
public boolean canAliceWin(String[] a, String[] b) {
int i = 1, j = 0;
boolean k = true;
String w = a[0];
while (true) {
if (k) {
if (j == b.length) {
return true;
}
if ((b[j].charAt(0) == w.charAt(0) && w.compareTo(b[j]) < 0)
|| b[j].charAt(0) - w.charAt(0) == 1) {
w = b[j];
k = !k;
}
++j;
} else {
if (i == a.length) {
return false;
}
if ((a[i].charAt(0) == w.charAt(0) && w.compareTo(a[i]) < 0)
|| a[i].charAt(0) - w.charAt(0) == 1) {
w = a[i];
k = !k;
}
++i;
}
}
}
}