Reveal Cells After a Click on a Mine Sweeping Game Board

Last updated: November 29, 2026

Quick Overview

Given a board of hidden mines and hidden empty cells and the coordinates of a click, update the board: a clicked mine is revealed as exploded, an empty cell with adjacent mines shows the count, and an empty cell with none becomes blank and reveals its neighbors recursively.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given a board of hidden mines and hidden empty cells and the coordinates of a click, update the board: a clicked mine is revealed as exploded, an empty cell with adjacent mines shows the count, and an empty cell with none becomes blank and reveals its neighbors recursively.

A Meta onsite simulation question tied to casual games like those in Facebook Gaming. It checks that you translate rules into a correct flood fill with eight-direction neighbors and that the expansion stops at numbered cells. Interviewers look closely at not revisiting cells and not mutating cells you should leave hidden.

What the Interviewer Expects
  • Handle the mine case first
  • Count mines among up to eight neighbors
  • Expand only from cells with zero adjacent mines
  • Use BFS or iterative DFS to avoid recursion limits
  • Avoid enqueuing the same cell twice
Key Topics to Cover
BFS
Flood fill
Simulation
Grid traversal
Eight-direction neighbors
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you generate a board so the first click is never a mine?
  • What if the board is 10^4 x 10^4 and the click opens a huge region?
  • How would you implement the chord action (clicking a numbered cell whose flags are satisfied)?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Board up to 50 x 50 using 'M', 'E', 'B', 'X' and digit characters.
  • One click on a hidden cell ('M' or 'E').
  • Return the board after applying the reveal rules....
High-Level Design

If the click hits 'M', mark it 'X' and stop. Otherwise run BFS from the clicked cell. For each popped hidden empty cell, count adjacent mines. If the count is positive, write the digit and do not expa...


Submit Your Answer
Markdown supported