Back to problems

Implement a Tic-Tac-Toe game class

Object-Oriented Programming · Microsoft · Medium

Approach 1: Explicit Board and Line Scanning The most direct way to model the game is to keep the full n x n board in memory. On every move, record the player's mark in the grid. Since the newly placed mark is the only cell that could have just completed a winning line, inspect the line segments that pass through (row, col): the current row, the current column, and, if the cell belongs to either diagonal, that diagonal as well. Checking a line means walking all n cells in…

Checking your access…