Design a Tic-Tac-Toe game that is played on an n x n grid between two players.
You may assume the following rules:
- A move is guaranteed to be valid and is placed on an empty block.
- Once a winning condition is reached, no more moves is allowed.
- A player who succeeds in placing
nof their marks in a horizontal, vertical, or diagonal row wins the game. Implement theTicTacToeclass:
TicTacToe(int n)Initializes the object the size of the boardn.int move(int row, int col, int player)Indicates that the player with idplayerplays at the cell(row, col). The player will be either 1 or 2.
- Method calls.
Input: ["TicTacToe", "move", "move", "move"] [[3], [0, 0, 1], [0, 2, 2], [2, 2, 1]]
Output: [null, 0, 0, 1]