forked from DengWangBao/Leetcode-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlipGameII.java
More file actions
18 lines (17 loc) · 479 Bytes
/
FlipGameII.java
File metadata and controls
18 lines (17 loc) · 479 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class FlipGameII {
public boolean canWin(String s) {
for (int i = 0; i < s.length(); ) {
int index = s.indexOf("++", i);
if (index >= i) {
String t = s.substring(0, index) + "--" + s.substring(index + 2);
if (!canWin(t)) {
return true;
}
i = index + 1;
} else {
break;
}
}
return false;
}
}