Practice Minesweeper
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Update board after clicking one unrevealed cell. M denotes an unrevealed mine, E an unrevealed empty cell, B a revealed empty cell with no adjacent mines, digits 1 through 8 the number of adjacent mines, and X a revealed mine. Adjacency includes all eight surrounding positions. Clicking M changes it to X and ends the update. For an E cell, count adjacent mines: if the count is positive, replace E with that digit; otherwise replace it with B and reveal each adjacent unrevealed cell by the same rules. Stop when there are no further cells to reveal and return the updated board. The click array gives [row, column].
Source: Minesweeper on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
board = [["E","E","E","E","E"],["E","E","M","E","E"],["E","E","E","E","E"],["E","E","E","E","E"]], click = [3,0]
[["B","1","E","1","B"],["B","1","M","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]]
# Example 2
board = [["B","1","E","1","B"],["B","1","M","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]], click = [1,2]
[["B","1","E","1","B"],["B","1","X","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]]
Constraints
Related LeetCode Problems
Practice more problems similar to Minesweeper.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.