Tic-Tac-Toe Game Status
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.
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.
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
Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.