Skip to content

Commit e089949

Browse files
flip game
1 parent 404865d commit e089949

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

EASY/src/easy/FlipGame.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package easy;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class FlipGame {
7+
8+
public List<String> generatePossibleNextMoves(String s) {
9+
10+
List<String> result = new ArrayList<String>();
11+
for(int i = 1; i < s.length(); i++){
12+
if(s.charAt(i) == '+' && s.charAt(i-1) == '+'){
13+
result.add(s.substring(0, i-1) + "--" + s.substring(i+1));
14+
}
15+
}
16+
return result;
17+
18+
}
19+
20+
}

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
|301|[Remove Invalid Parentheses](https://leetcode.com/problems/remove-invalid-parentheses/)|[Solution]| ? | ? | Hard| BFS
4444
|299|[Bulls and Cows](https://leetcode.com/problems/bulls-and-cows/)|[Solution](../../blob/master/EASY/src/easy/BullsandCows.java)| O(n)|O(1) | Easy|
4545
|295|[Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream/)|[Solution](../../blob/master/HARD/src/hard/FindMedianFromDataStream.java)| O(nlogn) | O(n) | Hard| Heap
46+
|293|[Flip Game](https://leetcode.com/problems/flip-game/)|[Solution](../../blob/master/EASY/src/easy/FlipGame.java)| ?|O(n) | Easy|
4647
|292|[Nim Game](https://leetcode.com/problems/nim-game/)|[Solution](../../blob/master/EASY/src/easy/NimGame.java)| O(1)|O(1) | Easy|
4748
|290|[Word Pattern](https://leetcode.com/problems/word-pattern/)|[Solution](../../blob/master/EASY/src/easy/WordPattern.java)| O(n)|O(n) | Easy|
4849
|289|[Game of Life](https://leetcode.com/problems/game-of-life/)|[Solution](../../blob/master/MEDIUM/src/medium/GameOfLife.java)| O(m*n)|O(m*n), could be optimized to O(1) | Medium|

0 commit comments

Comments
 (0)