Practice Valid Tic-Tac-Toe State
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Return whether board can occur in a valid 3 by 3 tic-tac-toe game. Spaces are empty cells. X moves first, then X and O alternate, placing their mark only in an empty cell. Play stops immediately when a player has three matching marks in any row, column or diagonal, or when the board is full. No move may occur after the game ends.
Source: Valid Tic-Tac-Toe State on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
board = ["O "," "," "]
Output
false
# Example 2
Input
board = ["XOX"," X "," "]
Output
false
# Example 3
Input
board = ["XOX","O O","XOX"]
Output
true
Constraints
board.length == 3
board[i].length == 3
board[i][j] is either 'X', 'O', or ' '.
Related LeetCode Problems
Practice more problems similar to Valid Tic-Tac-Toe State.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.