Problem · Matrix

Tic-Tac-Toe Game Status

MediumGoogle logoGoogleFULLTIMENEW GRADPHONE SCREEN
See Google hiring insights

Problem statement

Design the move-processing logic for a generalized Tic-Tac-Toe game.

There are k players and an n x n board. Players take turns placing their own mark on an empty cell. Player numbers are 1 through k. Each move is encoded as [player, row, col], specifying which player is acting and which cell they target; no strict turn-order enforcement is applied beyond what is encoded in the move list.

A player wins as soon as they have at least 3 consecutive marks in a straight line. The line may be horizontal, vertical, diagonal, or anti-diagonal. This winning length is always 3, even when n is larger than 3.

The problem statement continues
Pro

Examples

Example 1

k = 2n = 3moves = [[1,0,0],[2,1,0],[1,0,1],[2,1,1],[1,0,2]]return = ["In Progress","In Progress","In Progress","In Progress","Player 1 won"]

Player 1 completes three consecutive marks across the top row.

FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$9/month

Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week