Tap here to switch tabs
Problem
Submissions

Problem: Valid Tic-Tac-Toe State

med
30 min
Try to solve the Valid Tic-Tac-Toe State problem.

Statement

Given a 3imes33 imes 3 Tic Tac Toe board represented as an array of strings board, return true if it is possible to reach this board state during a valid game, or false otherwise.

The game is played according to the following rules:

  • Players take turns placing characters on the board, where the first player always plays 'X' and the second player always plays 'O'.

  • Characters can only be placed in empty spaces, which are represented by ' '.

  • The game ends immediately when three identical non-empty characters align in any row, column, or diagonal, or when all 99 squares are filled.

  • No moves can be made once the game has ended.

Constraints:

  • board.length =3= 3

  • board[i].length =3= 3

  • board[i][j] is either 'X', 'O', or ' '.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Valid Tic-Tac-Toe State

med
30 min
Try to solve the Valid Tic-Tac-Toe State problem.

Statement

Given a 3imes33 imes 3 Tic Tac Toe board represented as an array of strings board, return true if it is possible to reach this board state during a valid game, or false otherwise.

The game is played according to the following rules:

  • Players take turns placing characters on the board, where the first player always plays 'X' and the second player always plays 'O'.

  • Characters can only be placed in empty spaces, which are represented by ' '.

  • The game ends immediately when three identical non-empty characters align in any row, column, or diagonal, or when all 99 squares are filled.

  • No moves can be made once the game has ended.

Constraints:

  • board.length =3= 3

  • board[i].length =3= 3

  • board[i][j] is either 'X', 'O', or ' '.