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/_529.java
+52-40Lines changed: 52 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@
4
4
importjava.util.Queue;
5
5
6
6
/**
7
+
* 529. Minesweeper
8
+
*
7
9
* Let's play the minesweeper game (Wikipedia, online game)!
8
10
9
11
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.
@@ -14,6 +16,7 @@ If a mine ('m') is revealed, then the game is over - change it to 'X'.
14
16
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
17
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
18
Return the board when no more squares will be revealed.
19
+
17
20
Example 1:
18
21
Input:
19
22
@@ -33,6 +36,7 @@ If an empty square ('E') with at least one adjacent mine is revealed, then chang
33
36
34
37
Explanation:
35
38
39
+
36
40
Example 2:
37
41
Input:
38
42
@@ -59,60 +63,68 @@ The click position will only be an unrevealed square ('m' or 'E'), which also me
59
63
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.