Description

Given a minesweeper board and click position, update and return the board after revealing that square according to minesweeper rules.

Examples

Input:board = [["E","E","E"],["E","E","M"],["E","E","E"]], click = [0,0]
Output:[["B","1","E"],["B","1","M"],["B","1","E"]]
Explanation:

Reveal from click.

Input:board = [["E","E","E","E"],["E","M","M","E"],["E","E","E","E"]], click = [1,1]
Output:[["E","E","E","E"],["E","X","M","E"],["E","E","E","E"]]
Explanation:

Clicking on a mine cell [1,1] reveals the mine as 'X' and ends the game. No other cells are revealed when a mine is clicked.

Input:board = [["E","E","E"],["E","M","E"],["M","E","M"]], click = [0,1]
Output:[["E","3","E"],["E","M","E"],["M","E","M"]]
Explanation:

Clicking on [0,1] reveals a '3' because there are exactly 3 adjacent mines. Since this cell has adjacent mines, no blank area expansion occurs, so only this single cell is revealed.

Constraints

  • 1 ≤ m, n ≤ 50

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!