Description
Design a Tic-tac-toe game that is played between two players on an n x n grid. Implement move() that returns the winner if move causes a win.
Examples
Input:
n = 3, moves = [[0,0,1],[0,2,2],[2,2,1],[1,1,2],[2,0,1],[1,0,2],[2,1,1]]Output:
[0,0,0,0,0,0,1]Explanation:
Player 1 wins on column 2.
Input:
n = 3, moves = [[1]]Output:
[1]Explanation:
Minimal case with a single move.
Input:
n = 4, moves = [[0,0,1],[1,1,2],[0,1,1],[2,2,2],[0,2,1],[3,3,2],[0,3,1]]Output:
[0,0,0,0,0,0,1]Explanation:
Player 1 wins by completing the top row (row 0) with positions [0,0], [0,1], [0,2], [0,3]. The game progresses with no winner until the final move when player 1 places at [0,3] to complete 4 in a row horizontally.
Constraints
- •
2 ≤ n ≤ 100