SevyDevy

Design tic-tac-toe

PremiumLow-level designEasy

  • Win detection
  • Strategy pattern
  • Minimax

Quick answer

This low-level design interview question asks you to design tic-tac-toe. Aim for a design that is modelled as clear classes, interfaces and relationships that can handle new requirements without a rewrite. Interviewers want to see how you name responsibilities, keep classes small and reason about change.

The problem

Tic-Tac-Toe low level design: build the object model for the game where two players place symbols on an N × N board and the first to fill a row, column or diagonal wins. The hard parts are O(1) win detection, an undo that restores the counters, and a computer player that plugs in as a strategy.

Two players take turns placing their symbol on an empty cell. A full board with no winner is a draw. The board may be larger than 3 × 3, one player may be a computer, and the game must support undo.

What must the system do?

  • Moves: A move names a row and column. It is rejected if the cell is taken, the coordinates are out of range, the game is over, or it is not that player's turn.
  • Win: A player wins by filling any row, any column or either main diagonal with N of their symbols.
5 more requirementsUnlock to see all

How well must it do it?

  • Fast win check: Deciding whether the last move won must be O(1), not a scan of the whole board, even for N = 10.
  • Correct: The game must never allow a move after it ends, and the turn must alternate strictly.
2 more requirementsUnlock to see all

What scale should you design for?

Use these numbers in your estimates.

The scale numbers unlock with this questionUnlock

Key concepts

  • Win detection
  • Strategy pattern
  • Minimax
  • Board games
  • Undo redo
  • Game state

How you’ll practise

6 short steps · save and come back any time
  1. Requirements
  2. Core objects
  3. Class relationships
  4. Key flows
  5. Extensibility
  6. Wrap-up

Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.

What do interviewers look for?

In any low-level design round.

  • Lists the use cases before writing classes
  • Gives each class one clear responsibility
  • Uses interfaces where behaviour is likely to change
  • Applies a design pattern only when it solves a real problem
  • Handles edge cases and invalid states explicitly
  • Walks through one use case end to end with the model

Questions people ask about this interview question

Which design type is this question?
It is a low-level design question. You design tic-tac-toe and explain your choices the way you would in an interview.
Is this question asked at entry level?
It is marked Easy, so it suits engineers who are new to low-level design interviews. It is also a good warm-up before harder questions.
What should I cover first?
Start with the use cases and the core entities, then the responsibilities of each one. Agree on scope with the interviewer before you design anything.
Can I practise it for free?
It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.

Related questions

Updated · Written by the SevyDevy team

Premium questionSign up free, then unlock it