Skip to content

Commit c7f0398

Browse files
authored
Create Remove Colored Pieces if Both Neighbors are the Same Color.java
1 parent ea6f89d commit c7f0398

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public boolean winnerOfGame(String colors) {
3+
int alice = 0;
4+
int bob = 0;
5+
for (int i = 1; i < colors.length() - 1; i++) {
6+
if (colors.charAt(i - 1) == colors.charAt(i) && colors.charAt(i + 1) == colors.charAt(i)) {
7+
if (colors.charAt(i) == 'A') {
8+
alice++;
9+
} else {
10+
bob++;
11+
}
12+
}
13+
}
14+
return alice - bob > 0;
15+
}
16+
}

0 commit comments

Comments
 (0)