PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Nash AI

Implement Minesweeper click-to-reveal expansion

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to implement grid-based data structures, state management, and flood-fill style expansion logic for Minesweeper, including correct handling of mine revelation and idempotent re-click behavior.

  • medium
  • Nash AI
  • Coding & Algorithms
  • Software Engineer

Implement Minesweeper click-to-reveal expansion

Company: Nash AI

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem Implement a playable **text-based Minesweeper** engine. You are given a board size and mine locations (or a mine count with a deterministic placement method). Implement initialization and the **click** operation. ### Setup - Board has `height` rows and `width` columns. - Some cells contain mines. - Each non-mine cell stores the number of adjacent mines (8-directional neighbors). ### Click behavior Implement `click(r, c)` with these rules: 1. If `(r, c)` contains a mine, mark it as revealed and the game is over. 2. Otherwise reveal `(r, c)`. 3. If the revealed cell’s adjacent-mine count is **0**, recursively/iteratively reveal all connected zero-cells **and** their boundary non-zero neighbors (standard Minesweeper expansion). 4. Re-clicking an already revealed cell should be a no-op. ### I/O / Interaction - Provide functions/classes so a user can “play” via repeated clicks. - Visualization can be done using `print` (e.g., hidden cells shown as `#`, revealed numbers as `0-8`, mines as `*` only when revealed). ### Constraints - `1 ≤ width, height ≤ 200` (assume up to 40,000 cells). - Mines can be up to `width*height - 1`. - Your expansion must avoid stack overflow (i.e., recursion depth issues) on large boards. ### What to deliver - Data structures for the board state. - Efficient click expansion implementation. - A simple loop/demo showing the board after each click.

Quick Answer: This question evaluates a candidate's ability to implement grid-based data structures, state management, and flood-fill style expansion logic for Minesweeper, including correct handling of mine revelation and idempotent re-click behavior.

Related Interview Questions

  • Implement Minesweeper click and print - Nash AI (Medium)
Nash AI logo
Nash AI
Oct 21, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
1
0
Loading...

Problem

Implement a playable text-based Minesweeper engine.

You are given a board size and mine locations (or a mine count with a deterministic placement method). Implement initialization and the click operation.

Setup

  • Board has height rows and width columns.
  • Some cells contain mines.
  • Each non-mine cell stores the number of adjacent mines (8-directional neighbors).

Click behavior

Implement click(r, c) with these rules:

  1. If (r, c) contains a mine, mark it as revealed and the game is over.
  2. Otherwise reveal (r, c) .
  3. If the revealed cell’s adjacent-mine count is 0 , recursively/iteratively reveal all connected zero-cells and their boundary non-zero neighbors (standard Minesweeper expansion).
  4. Re-clicking an already revealed cell should be a no-op.

I/O / Interaction

  • Provide functions/classes so a user can “play” via repeated clicks.
  • Visualization can be done using print (e.g., hidden cells shown as # , revealed numbers as 0-8 , mines as * only when revealed).

Constraints

  • 1 ≤ width, height ≤ 200 (assume up to 40,000 cells).
  • Mines can be up to width*height - 1 .
  • Your expansion must avoid stack overflow (i.e., recursion depth issues) on large boards.

What to deliver

  • Data structures for the board state.
  • Efficient click expansion implementation.
  • A simple loop/demo showing the board after each click.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Nash AI•More Software Engineer•Nash AI Software Engineer•Nash AI Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.