FastPrepChoose the Next Minesweeper Action
Problems/Choose the Next Minesweeper Action

Choose the Next Minesweeper Action

Runloop logoRunloop● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The bot’s next-action capability matches the brief interview report at about 60%. Choosing where to mark or reveal from exposed numbers is reported directly. The bounded board, probability prior, exact one-step policy, encoding and ties are explicit practice definitions.

Choose one next action for a Minesweeper bot from the currently visible board. A revealed number tells you how many mines are in its neighboring cells. There are at most eight neighbors, including diagonals. Do not include the numbered cell itself.

For this bounded practice exercise, board[r][c] is -1 for an unknown cell, -2 for an already flagged known mine, or a number from 0 through 8 for a revealed safe cell. Flags are assumed correct. Hidden mine locations are not supplied.

Explicit probability model

Start by treating every way to mark the unknown cells as mines or safe as equally likely. Keep only the assignments that agree with every visible number and existing flag. Each remaining assignment is equally likely. You are not given the total number of mines. At least one assignment is guaranteed to match the board.

One-step action contract

  1. If no unknown cell remains, return [2, -1, -1] for DONE.
  2. If any unknown cell is a mine in every consistent assignment, return [1, row, col] for FLAG, choosing the first such cell in row-major order.
  3. Otherwise return [0, row, col] for REVEAL at the unknown cell with the lowest mine probability across all consistent assignments. Break ties by row-major order.

Coordinates are zero-based. Return only the action; do not change the board or simulate a reveal. Minimum immediate reveal risk under this model does not claim a globally optimal strategy for winning a complete game.

Function

nextMinesweeperAction(board: int[][]) → int[]

Examples

Example 1

board = [[0,-1],[-1,-1]]return = [0,0,1]
board
0100-11-1-1

All three unknown neighbors are safe in every consistent assignment; reveal the first in row-major order.

Example 2

board = [[1,-1]]return = [1,0,1]
board
0101-1

The single unknown neighbor must be a mine; return FLAG at row 0 column 1.

Example 3

board = [[-1,-1]]return = [0,0,0]
board
010-1-1

Both unknown cells have mine probability one-half under the explicit prior; reveal row 0 column 0 by the tie rule.

Constraints

  • The rectangular board has from 1 through 4 rows and columns.
  • There are at most 15 unknown cells.
  • Every entry is -2, -1, or an integer from 0 through 8.
  • Every revealed number is consistent with at least one assignment to all unknown cells, treating existing flags as mines.
  • Use all visible clues together; assignments outside the board do not exist.

More Runloop Phone Screen questions

  • In-Memory Meeting Room ManagerPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Maximum Words in Disjoint Grid PathsIndeed · PHONE SCREENIndeed interview questions
  • Boggle GameAirbnb · PHONE SCREENAirbnb interview questions
  • Count Eight-Neighbor Unlock PatternsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Knights, Knaves and Their StatementsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Prefix Matrix Products and AutogradOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Sudoku Puzzle SolverConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Visit Desired Attractions Without Reusing a TrailDuolingo · PHONE SCREENDuolingo interview questions
  • Best-Fit Plane Normal from 3D PointsThe Voleon Group · PHONE SCREEN
  • Maximum Currency Conversion Along a Simple PathRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Town Temperature Regression AnalysisCitadel · PHONE SCREENCitadel interview questions
See Runloop hiring insights
Saved
class Solution {
    public int[] nextMinesweeperAction(int[][] board) {
        // write your code here
    }
}
Checking account…