Simulate a Turn-Based Two-Player Game
Company: OpenAI
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Design and implement a simulator for a two-player turn-based board game similar to tic-tac-toe.
Requirements:
- The game is played on an `n x n` board.
- Two players, `A` and `B`, take turns placing a mark on an empty cell.
- A move is invalid if it is outside the board, targets an occupied cell, or is made after the game has already ended.
- After each move, the program should report one of four states: `A wins`, `B wins`, `draw`, or `game continues`.
- The interface should support both processing moves one at a time and evaluating a full sequence of moves to predict the final winner.
Focus on clean API design, correctness, and reasonable time and space complexity.
Quick Answer: This question evaluates API design, state management, move validation, board representation, and correctness guarantees for a turn-based game simulator. It falls under the Coding & Algorithms domain and is commonly asked to assess edge-case handling, time/space complexity awareness and practical application of algorithmic thinking and software design at the implementation level.