Reported April 2025
Claydepth first search

Minesweeper Board Update

Reported by candidates from Clay's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Clay OA. Under 2s to a working solution.
Founder's read

The Clay OA reported in April 2025 hands you a Minesweeper click and asks for the board after it. It looks like a game sim, but it's a flood fill with one rule that trips people up. Clicking a mine is the easy branch. The real work is expanding through zero-count cells while stopping at numbered ones. It's a DFS or BFS on a grid, and the whole question is whether you mark cells before or after you recurse. If you've got an invite in your inbox, this is the shape to expect. StealthCoder sits invisibly as a safety net on the live OA if your mind goes blank mid-solve.

The problem

You are given a rectangular Minesweeper board containing unrevealed empty cells E and unrevealed mines M, plus a clicked coordinate [row, column].
If the clicked cell is a mine, change it to X and return the board.
Otherwise reveal the clicked empty region. For an unrevealed empty cell, count mines in all eight neighboring positions.
If the count is positive, replace the cell with the digit 1 through 8 and do not expand through it.
If the count is zero, replace the cell with B and continue revealing all adjacent unrevealed empty cells.
Mutate and return the board after the click.

Function
updateBoard(board: char[][], click: int[]) → char[][]

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]
return = [["B","1","E","1","B"],["B","1","M","1","B"],["B","1","1","1","B"],["B","B","B","B","B"]]
The click opens a zero-mine region. Numbered boundary cells stop expansion, and the unrevealed cell behind the mine remains E.
Example 2
board = [["M","E"],["E","E"]]
click = [0,0]
return = [["X","E"],["E","E"]]
Clicking the mine marks only that cell as X.
Example 3
board = [["M","E"],["E","E"]]
click = [1,1]
return = [["M","E"],["E","1"]]
The clicked cell touches one mine, so it becomes 1 and expansion stops immediately.

Constraints
1 <= board.length, board[0].length <= 300
Every row has the same length.
Each board cell is E or M.
click contains a valid board coordinate.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is flood fill over eight directions. Start at the click. If it's M, set X and return. Otherwise, count adjacent mines first. If the count is positive, write the digit and stop. If zero, write B and visit every neighbor that's still E. The mistake that sinks a first attempt is recursing before you've changed the cell, or only checking four directions. Either one gives infinite loops or wrong boards. Changing the cell on entry doubles as your visited check, so you don't need a separate set. With boards up to 300 by 300, recursive DFS can blow the stack in some languages, so a BFS queue is safer. Don't expand through numbered cells, and don't touch mines during expansion. If you freeze on the stopping rule during the live OA, StealthCoder is the hedge that reads the problem and hands you a clean solution.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Minesweeper Board Update cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as minesweeper. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Clay's OA.

Clay reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minesweeper Board Update FAQ

What's the trick in Minesweeper Board Update?+

It's a flood fill. Count the eight neighbors' mines for the current cell. If the count is above zero, write the digit and stop. If it's zero, write B and recurse into all unrevealed E neighbors. Mutating the cell on entry prevents revisiting.

Should I use DFS or BFS here?+

Either works, but BFS with a queue avoids recursion depth issues on a 300 by 300 board. An all-zero board can chain 90,000 cells deep in DFS. Mark each cell as revealed when you enqueue it, not when you pop it, so it isn't queued twice.

What's the most common bug?+

Expanding through numbered cells, or checking only four directions. The mine count uses all eight neighbors, and expansion also uses all eight. Another frequent bug is forgetting to mark the cell before recursing, which causes duplicate work or infinite loops.

How hard is this really?+

It's a medium. The logic is short once you see it's flood fill. Edge cases are bounds checks, clicking a mine directly, and a numbered click that stops immediately. Example 3 covers that last one, so test it yourself before submitting.

How do I prepare in 48 hours?+

Write grid flood fill from scratch twice, once DFS and once BFS, using eight-direction offsets. Then trace the three examples by hand. Pay attention to where the count check happens relative to the mutation. That covers nearly every way this problem goes wrong.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Clay.

OA at Clay?
Invisible during screen share
Get it