Minesweeper
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given a Minesweeper board as a grid of characters and the cell the player clicks. Cell meanings:
- 'M' an unrevealed mine, 'E' an unrevealed empty cell
- 'B' a revealed blank (no adjacent mines), '1'..'8' a revealed cell showing how many mines touch it (8 directions)
- 'X' a revealed mine
The clicked cell click = [row, col] is always unrevealed ('M' or 'E'). Apply these rules and return the updated board:
1. Clicking a mine turns it into 'X', and nothing else changes.
2. Clicking an 'E' with at least one adjacent mine turns it into the digit for that count, and nothing else changes.
3. Clicking an 'E' with no adjacent mines turns it into 'B', and every adjacent unrevealed 'E' is revealed by the same rules, recursively. The cascade stops at cells that show digits.
Examples
Constraints
- `1 <= m, n <= 50`
- `board[i][j]` is one of `'M'`, `'E'`, `'B'`, `'X'`, `'1'`-`'8'`
- `board[click[0]][click[1]]` is `'M'` or `'E'`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.