A moves first and places crosses, player B places noughts; they alternate and always pick an empty cell. The game ends as soon as someone has three of their marks in a row, column or diagonal, or when every cell is filled. No moves are made after the game is over.
You are given the list moves, where moves[i] = [row, col] is the cell taken on the i-th move (rows and columns are numbered from zero). The moves follow the rules above, and the board starts empty.
Return "A" or "B" if that player has won, "Draw" if the board is full with no winner, and "Pending" if the game is not over yet.moves=[[1, 1], [0, 0], [0, 2], [2, 2], [2, 0]] → 'A'
The X marks sit at (1,1), (0,2) and (2,0), the anti-diagonal, so A wins.
moves=[[0, 0], [1, 0], [0, 1], [1, 1], [2, 2], [1, 2]] → 'B'
The O marks fill the whole middle row, so B wins.
moves=[[2, 1], [0, 1]] → 'Pending'
Only two moves have been made, no line is complete and empty cells remain, so the game goes on.
moves.length ≤ 9moves[i].length == 2row, col ≤ 2moves twicemoves=[[1, 1], [0, 0], [0, 2], [2, 2], [2, 0]]
'A'
Run checks the first 3 tests in your browser. Submit checks all 87 tests on the server, hidden ones included.