Tic-Tac-Toe

An N x N board game with pluggable players and constant-time win detection.

Easy30 minGame loopStrategyO(1) win check

Design a Tic-Tac-Toe game that two players (human or bot) can play on an N x N board. It's a warm-up problem, but interviewers use it to check clean modelling, a tidy game loop, and whether you can detect a win in O(1) instead of rescanning the board.

Requirements

Functional

  • Two players take turns placing their symbol (X or O) on an empty cell.
  • Board size is configurable (default 3 x 3); a player wins with N in a row, column, or diagonal.
  • Detect win and draw; reject moves on occupied or out-of-range cells and moves out of turn.
  • Players can be humans (input-driven) or bots (strategy-driven).
  • Optional: undo the last move, replay a finished game.

Non-functional

  • Move validation and win check should be O(1) per move.
  • Easy to add new player types or a larger board without changing game logic.
  • Single process; one game object per match, no concurrency needed across games.

Try it first

Set a timer, sketch your own design on paper, then compare it with the reference walkthrough.

30:00

Complete & continue

Defend it out loud

The AI interviewer will probe your design for Tic-Tac-Toe and score it.

Mock interview