Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite089949

Browse files
flip game
1 parent404865d commite089949

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

‎EASY/src/easy/FlipGame.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
packageeasy;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.List;
5+
6+
publicclassFlipGame {
7+
8+
publicList<String>generatePossibleNextMoves(Strings) {
9+
10+
List<String>result =newArrayList<String>();
11+
for(inti =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+
returnresult;
17+
18+
}
19+
20+
}

‎README.md

Lines changed: 1 addition & 0 deletions
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)

[8]ページ先頭

©2009-2025 Movatter.jp