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

Commitd59df89

Browse files
refactor 488
1 parent6ca4a2b commitd59df89

File tree

1 file changed

+0
-36
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-36
lines changed

‎src/main/java/com/fishercoder/solutions/_488.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,5 @@
11
packagecom.fishercoder.solutions;
22

3-
/**
4-
* 488. Zuma Game
5-
*
6-
* Think about Zuma Game. You have a row of balls on the table, colored red(R), yellow(Y), blue(B), green(G), and white(W).
7-
* You also have several balls in your hand.
8-
9-
Each time, you may choose a ball in your hand, and insert it into the row (including the leftmost place and rightmost place).
10-
Then, if there is a group of 3 or more balls in the same color touching, remove these balls. Keep doing this until no more balls can be removed.
11-
12-
Find the minimal balls you have to insert to remove all the balls on the table. If you cannot remove all the balls, output -1.
13-
14-
Examples:
15-
16-
Input: "WRRBBW", "RB"
17-
Output: -1
18-
Explanation: WRRBBW -> WRR[R]BBW -> WBBW -> WBB[B]W -> WW
19-
20-
Input: "WWRRBBWW", "WRBRW"
21-
Output: 2
22-
Explanation: WWRRBBWW -> WWRR[R]BBWW -> WWBBWW -> WWBB[B]WW -> WWWW -> empty
23-
24-
Input:"G", "GGGGG"
25-
Output: 2
26-
Explanation: G -> G[G] -> GG[G] -> empty
27-
28-
Input: "RBYYBBRRB", "YRBGB"
29-
Output: 3
30-
Explanation: RBYYBBRRB -> RBYY[Y]BBRRB -> RBBBRRB -> RRRB -> B -> B[B] -> BB[B] -> empty
31-
32-
Note:
33-
34-
You may assume that the initial row of balls on the table won’t have any 3 or more consecutive balls with the same color.
35-
The number of balls on the table won't exceed 20, and the string represents these balls is called "board" in the input.
36-
The number of balls in your hand won't exceed 5, and the string represents these balls is called "hand" in the input.
37-
Both input strings will be non-empty and only contain characters 'R','Y','B','G','W'.
38-
*/
393
publicclass_488 {
404

415
publicstaticclassSolution1 {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp