Description
Tic-tac-toe is played on a 3x3 grid by two players A and B who alternately place X and O. Given an array of moves, determine the winner. Return "A", "B", "Draw", or "Pending".
Examples
Input:
moves = [[0,0],[2,0],[1,1],[2,1],[2,2]]Output:
"A"Explanation:
A wins diagonally.
Input:
moves = [[0,0],[1,1],[0,1],[1,2],[0,2]]Output:
AExplanation:
A wins with a horizontal line in the top row (positions [0,0], [0,1], [0,2]).
Input:
moves = [[0,0],[0,1],[1,0],[1,1],[2,1],[2,2]]Output:
PendingExplanation:
After 6 moves, no player has achieved three in a row. The game is still ongoing with 3 empty positions remaining.
Constraints
- •
1 ≤ moves.length ≤ 9