We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a55f997 commit ee38423Copy full SHA for ee38423
Easy/Flip Game.java
@@ -1,11 +1,11 @@
1
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
- }
+ public List<String> generatePossibleNextMoves(String currentState) {
+ List<String> moves = new ArrayList<>();
+ for (int i = 0; i < currentState.length() - 1; i++) {
+ if (currentState.substring(i, i + 2).equals("++")) {
+ moves.add(currentState.substring(0, i) + "--" + currentState.substring(i + 2));
+ }
8
9
+ return moves;
10
}
- return list;
11
0 commit comments