Bird
Raised Fist0

How can you optimize win condition checking in a large board game to avoid scanning the entire board after each move?

hard📝 Trade-off Q9 of Q15
LLD - Design — Tic-Tac-Toe Game
How can you optimize win condition checking in a large board game to avoid scanning the entire board after each move?
ARecalculate the entire board state after every move
BTrack counts of consecutive marks per row, column, and diagonals for each player
COnly check the first row and column for wins
DUse random sampling of board cells to guess a win
Step-by-Step Solution
Solution:
  1. Step 1: Understand optimization techniques

    Tracking counts per row, column, and diagonal allows constant time win checks after each move.
  2. Step 2: Evaluate other options

    Recalculating entire board or sampling is inefficient or inaccurate; checking only first row/column misses wins.
  3. Final Answer:

    Track counts of consecutive marks per row, column, and diagonals for each player -> Option B
  4. Quick Check:

    Use counters for fast win check [OK]
Quick Trick: Use counters to avoid full scans [OK]
Common Mistakes:
MISTAKES
  • Recalculating full board
  • Ignoring diagonals
  • Using random guesses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes