You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/main/java/com/fishercoder/solutions/_174.java
+1-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
/**174. Dungeon Game
6
6
7
-
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the princess.
7
+
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of m x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the princess.
8
8
9
9
The knight has an initial health point represented by a positive integer. If at any point his health point drops to 0 or below, he dies immediately.
Copy file name to clipboardexpand all lines: src/main/java/com/fishercoder/solutions/_482.java
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
packagecom.fishercoder.solutions;
2
2
3
3
/**
4
-
* Now you are given a string S, which represents a software license key which we would like to format. The string S is composed of alphanumerical characters and dashes. The dashes split the alphanumerical characters within the string into groups. (i.e. if there are M dashes, the string is split into M+1 groups). The dashes in the given string are possibly misplaced.
4
+
* Now you are given a string S, which represents a software license key which we would like to format. The string S is composed of alphanumerical characters and dashes. The dashes split the alphanumerical characters within the string into groups. (i.e. if there are m dashes, the string is split into m+1 groups). The dashes in the given string are possibly misplaced.
5
5
6
6
We want each group of characters to be of length K (except for possibly the first group, which could be shorter, but still must contain at least one character). To satisfy this requirement, we will reinsert dashes. Additionally, all the lower case letters in the string must be converted to upper case.
Copy file name to clipboardexpand all lines: src/main/java/com/fishercoder/solutions/_529.java
+7-7
Original file line number
Diff line number
Diff line change
@@ -6,19 +6,19 @@
6
6
/**
7
7
* Let's play the minesweeper game (Wikipedia, online game)!
8
8
9
-
You are given a 2D char matrix representing the game board. 'M' represents an unrevealed mine, 'E' represents an unrevealed empty square, 'B' represents a revealed blank square that has no adjacent (above, below, left, right, and all 4 diagonals) mines, digit ('1' to '8') represents how many mines are adjacent to this revealed square, and finally 'X' represents a revealed mine.
9
+
You are given a 2D char matrix representing the game board. 'm' represents an unrevealed mine, 'E' represents an unrevealed empty square, 'B' represents a revealed blank square that has no adjacent (above, below, left, right, and all 4 diagonals) mines, digit ('1' to '8') represents how many mines are adjacent to this revealed square, and finally 'X' represents a revealed mine.
10
10
11
-
Now given the next click position (row and column indices) among all the unrevealed squares ('M' or 'E'), return the board after revealing this position according to the following rules:
11
+
Now given the next click position (row and column indices) among all the unrevealed squares ('m' or 'E'), return the board after revealing this position according to the following rules:
12
12
13
-
If a mine ('M') is revealed, then the game is over - change it to 'X'.
13
+
If a mine ('m') is revealed, then the game is over - change it to 'X'.
14
14
If an empty square ('E') with no adjacent mines is revealed, then change it to revealed blank ('B') and all of its adjacent unrevealed squares should be revealed recursively.
15
15
If an empty square ('E') with at least one adjacent mine is revealed, then change it to a digit ('1' to '8') representing the number of adjacent mines.
16
16
Return the board when no more squares will be revealed.
17
17
Example 1:
18
18
Input:
19
19
20
20
[['E', 'E', 'E', 'E', 'E'],
21
-
['E', 'E', 'M', 'E', 'E'],
21
+
['E', 'E', 'm', 'E', 'E'],
22
22
['E', 'E', 'E', 'E', 'E'],
23
23
['E', 'E', 'E', 'E', 'E']]
24
24
@@ -27,7 +27,7 @@ If an empty square ('E') with at least one adjacent mine is revealed, then chang
27
27
Output:
28
28
29
29
[['B', '1', 'E', '1', 'B'],
30
-
['B', '1', 'M', '1', 'B'],
30
+
['B', '1', 'm', '1', 'B'],
31
31
['B', '1', '1', '1', 'B'],
32
32
['B', 'B', 'B', 'B', 'B']]
33
33
@@ -37,7 +37,7 @@ If an empty square ('E') with at least one adjacent mine is revealed, then chang
37
37
Input:
38
38
39
39
[['B', '1', 'E', '1', 'B'],
40
-
['B', '1', 'M', '1', 'B'],
40
+
['B', '1', 'm', '1', 'B'],
41
41
['B', '1', '1', '1', 'B'],
42
42
['B', 'B', 'B', 'B', 'B']]
43
43
@@ -54,7 +54,7 @@ If an empty square ('E') with at least one adjacent mine is revealed, then chang
54
54
55
55
Note:
56
56
The range of the input matrix's height and width is [1,50].
57
-
The click position will only be an unrevealed square ('M' or 'E'), which also means the input board contains at least one clickable square.
57
+
The click position will only be an unrevealed square ('m' or 'E'), which also means the input board contains at least one clickable square.
58
58
The input board won't be a stage when game is over (some mines have been revealed).
59
59
For simplicity, not mentioned rules should be ignored in this problem. For example, you don't need to reveal all the unrevealed mines when the game is over, consider any cases that you will win the game or flag any squares.
0 commit comments