FastPrepProcess Minesweeper Game Operations
Problems/Process Minesweeper Game Operations

Process Minesweeper Game Operations

Amperity logoAmperity● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amperity full-time phone screen. The report asks for Minesweeper board setup, actions, the end of the game, and interaction with a UI, and clearly leaves out flags. We chose fixed mine positions, the usual reveal rule for eight neighbors, and a standard snapshot after each action. Our version is about 60% the same as the reported question.

Play a Minesweeper game by applying a list of actions. The board has rows rows and cols columns, and mines lists the distinct zero-indexed mine coordinates.

Every operation has the form OPEN r c. Apply operations in order:

  • Opening a hidden mine reveals that mine and changes the game status to LOST.
  • Opening a hidden safe cell reveals its number of adjacent mines among the eight neighboring cells.
  • If that number is 0, also reveal its entire eight-directionally connected region of zero cells and every safe numbered cell bordering that region.
  • Opening an already revealed cell is a no-op.
  • The status becomes WON as soon as every non-mine cell is revealed.
  • After the game is WON or LOST, later operations leave the state unchanged.

After every operation, emit one string STATUS|BOARD. The board renders each row left to right and joins rows with /. Use # for a hidden cell, * for an opened mine, 0 for a revealed zero cell, and 1 through 8 for a revealed numbered cell. Return all emitted strings in operation order. Flag actions are not part of this exercise.

Function

playMinesweeper(rows: int, cols: int, mines: int[][], operations: String[]) → String[]

Examples

Example 1

rows = 3cols = 3mines = [[0,0]]operations = ["OPEN 2 2"]return = ["WON|#10/110/000"]

The opened zero expands through the connected zero region and reveals every bordering number. All eight safe cells become visible, so the game is won while the mine remains hidden.

Example 2

rows = 2cols = 2mines = [[0,1]]operations = ["OPEN 0 0","OPEN 0 1","OPEN 1 1"]return = ["RUNNING|1#/##","LOST|1*/##","LOST|1*/##"]

The first action reveals a numbered cell. The second opens the mine and loses the game. The last action cannot change the board because the game is already over.

Example 3

rows = 2cols = 3mines = [[0,1],[1,2]]operations = ["OPEN 0 0","OPEN 1 0","OPEN 0 2","OPEN 1 1"]return = ["RUNNING|1##/###","RUNNING|1##/1##","RUNNING|1#2/1##","WON|1#2/12#"]

These safe cells all have adjacent mines, so no flood fill occurs. The fourth action reveals the last safe cell and changes the status to WON.

Constraints

  • 1 ≤ rows, cols ≤ 50.
  • 0 ≤ mines.length < rows * cols.
  • Mine coordinates are distinct and within the board.
  • 1 ≤ operations.length ≤ 5000.
  • Every operation is a valid OPEN r c action whose coordinate lies within the board.
  • Operations are processed in their given order.

More Amperity Phone Screen questions

  • Draw Overlapping ASCII RectanglesPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Drop and Eliminate Adjacent PiecesSnowflake · PHONE SCREENSnowflake interview questions
  • Minesweeper Board UpdateUber · ONSITE INTERVIEWUber interview questions
  • Minesweeper Board UpdateClay · ONSITE INTERVIEW
  • Minesweeper Board UpdateAirbyte · ONSITE INTERVIEW
  • Matrix EscapeByteDance · PHONE SCREENByteDance interview questions
  • Minimum Time to Spread Through a GridAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Grid Infection with Recovery After D DaysOpenAI · PHONE SCREENOpenAI interview questions
  • Max Area of Island Without Changing the GridFlexport · PHONE SCREENFlexport interview questions
  • Reachable Exits in an Obstacle GridWhatNot · PHONE SCREENWhatNot interview questions
  • Days Until Poisoned Plants StabilizeApple · PHONE SCREENApple interview questions
All Amperity interview questionsSee Amperity hiring insights
Saved
class Solution {
    public String[] playMinesweeper(int rows, int cols, int[][] mines, String[] operations) {
      // write your code here
    }
}
Checking account…