Bird
0
0

You are designing a scalable win condition checker for an n x n board game. Which approach best balances efficiency and scalability?

hard📝 Trade-off Q15 of 15
LLD - Design — Tic-Tac-Toe Game
You are designing a scalable win condition checker for an n x n board game. Which approach best balances efficiency and scalability?
AOnly check the row, column, and diagonals related to the last move
BCheck all rows, columns, and both diagonals after every move
CCheck the entire board for a winner after every move
DCheck only the diagonals after every move
Step-by-Step Solution
Solution:
  1. Step 1: Understand the cost of checking all lines

    Checking all rows, columns, and diagonals after every move is expensive for large boards.
  2. Step 2: Focus on last move's related lines

    Only the row, column, and diagonals that include the last move can change the win state, so checking these is efficient and scalable.
  3. Final Answer:

    Only check the row, column, and diagonals related to the last move -> Option A
  4. Quick Check:

    Check only affected lines after move for efficiency [OK]
Quick Trick: Check only lines affected by last move for best performance [OK]
Common Mistakes:
MISTAKES
  • Checking entire board every time wastes resources
  • Ignoring diagonals in win checking
  • Checking unrelated rows or columns

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes