PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates proficiency in interactive UI development and stateful game logic, including turn management, board state representation, win/draw detection, input validation, and reset flow.

  • medium
  • Whatnot
  • Coding & Algorithms
  • Software Engineer

Build a Tic-Tac-Toe App

Company: Whatnot

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Implement a simple Tic-Tac-Toe mobile app that can be completed in a 45-minute coding interview. Requirements: - Display a 3x3 board. - Support two local players, `X` and `O`, taking alternating turns. - A player can place a mark only in an empty cell. - After every move, detect whether either player has won by completing a row, column, or diagonal. - Detect a draw when the board is full and there is no winner. - Prevent additional moves after the game is over. - Show the current game status: current player, winner, or draw. - Provide a reset button to start a new game. Focus on clean state management, readable UI code, and correctness rather than visual polish.

Quick Answer: This question evaluates proficiency in interactive UI development and stateful game logic, including turn management, board state representation, win/draw detection, input validation, and reset flow.

Implement the core game logic behind a simple Tic-Tac-Toe mobile app. Instead of building the UI, you are given a sequence of commands representing player taps and reset actions. Simulate the app exactly as it should behave on a 3x3 board. Rules: - The board starts empty. - Player X always goes first. - Players alternate turns only after a successful move. - A player may place a mark only in an empty cell. - After each successful move, check whether that player completed a row, column, or diagonal. - If the board becomes full with no winner, the game is a draw. - Once the game has a winner or is a draw, further move commands are ignored until a reset happens. - A reset clears the board and starts a new game with X. Return the final board state and the final game status. Use '.' to represent an empty cell in the returned board.

Constraints

  • 0 <= len(commands) <= 100000
  • The board size is always 3 x 3
  • For a valid move command, row and col are intended to be in the range [0, 2]
  • Invalid moves into occupied cells or after the game is over must be ignored
  • Only successful moves switch the current player

Examples

Input: [(0,0), (1,0), (0,1), (1,1), (0,2)]

Expected Output: (['XXX', 'OO.', '...'], 'Winner: X')

Explanation: X fills the entire top row on the fifth move and wins.

Input: [(0,0), (0,1), (0,2), (1,1), (1,0), (1,2), (2,1), (2,0), (2,2)]

Expected Output: (['XOX', 'XOO', 'OXX'], 'Draw')

Explanation: All 9 cells are filled without any player completing a row, column, or diagonal.

Input: []

Expected Output: (['...', '...', '...'], 'In Progress')

Explanation: No commands means the initial empty board is unchanged.

Input: [(0,0), (0,0), (1,1), (0,1)]

Expected Output: (['XX.', '.O.', '...'], 'In Progress')

Explanation: The second command tries to use an occupied cell, so it is ignored and O keeps the turn for the next valid move.

Input: [(0,0), (1,0), (0,1), (1,1), (0,2), (2,2), "RESET", (2,2), (2,2)]

Expected Output: (['...', '...', '..X'], 'In Progress')

Explanation: After X wins, further moves are ignored until RESET. The reset clears the board, then X places one mark at the bottom-right.

Input: [(0,0), (1,1), (0,1), (1,0), (2,2), (1,2)]

Expected Output: (['XX.', 'OOO', '..X'], 'Winner: O')

Explanation: O completes the middle row on the last move.

Hints

  1. Track four pieces of state: the board, the current player, the current status, and whether the game is over.
  2. After placing a mark at (row, col), you only need to check that row, that column, and possibly the two diagonals.
Last updated: May 15, 2026

Related Coding Questions

  • Count User Journey Prefixes - Whatnot (easy)
  • Build User Journey Path Summary - Whatnot (hard)

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.