Bird
Raised Fist0

Given the following 3x3 board state:

medium📝 Analysis Q13 of Q15
LLD - Design — Tic-Tac-Toe Game
Given the following 3x3 board state:
board = [["X", "O", "X"],
         ["O", "X", "O"],
         ["O", "X", "X"]]

Which of these checks will correctly identify a win for 'X' on the main diagonal?
Aboard[0][0] == board[1][1] == board[2][2] == "X"
Bboard[0][2] == board[1][1] == board[2][0] == "X"
Cboard[0][0] == board[0][1] == board[0][2] == "X"
Dboard[2][0] == board[2][1] == board[2][2] == "X"
Step-by-Step Solution
Solution:
  1. Step 1: Identify main diagonal positions

    Main diagonal cells are at positions (0,0), (1,1), and (2,2).
  2. Step 2: Check which option matches main diagonal and 'X'

    board[0][0] == board[1][1] == board[2][2] == "X" compares these exact positions to 'X', correctly checking the main diagonal win.
  3. Final Answer:

    board[0][0] == board[1][1] == board[2][2] == "X" -> Option A
  4. Quick Check:

    Main diagonal check = positions (0,0),(1,1),(2,2) [OK]
Quick Trick: Main diagonal is top-left to bottom-right [OK]
Common Mistakes:
MISTAKES
  • Confusing main diagonal with anti-diagonal
  • Checking wrong row or column
  • Using equality with wrong symbol

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes