Skip to content

Commit ee38423

Browse files
authored
Update Flip Game.java
1 parent a55f997 commit ee38423

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Easy/Flip Game.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
class Solution {
2-
public List<String> generatePossibleNextMoves(String currentState) {
3-
List<String> list = new ArrayList<>();
4-
for (int i = 1; i < currentState.length(); i++) {
5-
if (currentState.charAt(i) == '+' && currentState.charAt(i - 1) == '+') {
6-
list.add(currentState.substring(0, i - 1) + "--" + currentState.substring(i + 1));
7-
}
2+
public List<String> generatePossibleNextMoves(String currentState) {
3+
List<String> moves = new ArrayList<>();
4+
for (int i = 0; i < currentState.length() - 1; i++) {
5+
if (currentState.substring(i, i + 2).equals("++")) {
6+
moves.add(currentState.substring(0, i) + "--" + currentState.substring(i + 2));
7+
}
8+
}
9+
return moves;
810
}
9-
return list;
10-
}
1111
}

0 commit comments

Comments
 (0)