FastPrepTic-Tac-Toe Game Over
Problems/Tic-Tac-Toe Game Over

Tic-Tac-Toe Game Over

ByteDance logoByteDance● EasyFULLTIMENEW GRADPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report establishes the task identity and central capability. This practice contract supplies only the portable interface, deterministic boundary rules, and output serialization needed for consistent execution.

You are given an n × n tic-tac-toe board encoded as n strings. Cells contain 'X', 'O', or '.' for empty.

Return true if the game is over: either one player fills an entire row, column, main diagonal, or anti-diagonal, or the board is full and has no winner. Otherwise return false.

Function

gameOver(board: String[]) → boolean

Examples

Example 1

board = ["XXX","O.O","..O"]return = true

X fills the first row.

Example 2

board = ["XO","OX"]return = true

The board is full, so the game ended even without considering another move.

Constraints

  • 1 <= n <= 500.
  • Every row has length n and uses only X, O, and ..

More ByteDance problems

  • Binary Tree Target-Sum PathsPHONE SCREEN · Seen Nov 2026
  • Longest Increasing SubsequencePHONE SCREEN · Seen Nov 2026
  • Alien DictionaryPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
All ByteDance interview questionsSee ByteDance hiring insights
Saved
class Solution {
    public boolean gameOver(String[] board) {
      // write your code here
    }
}
Checking account…