Design an algorithm to figure out if someone has won a game of tic-tac-toe. Input is a string array of size N x N, including characters " ", "X" and "O", where " " represents a empty grid.
The rules of tic-tac-toe are as follows:
If there is any winner, return the character that the winner used. If there's a draw, return "Draw". If the game doesn't end and there is no winner, return "Pending".
Example 1:
Input: board = ["O X"," XO","X O"] Output: "X"
Example 2:
Input: board = ["OOX","XXO","OXO"] Output: "Draw" Explanation: no player wins and no empty grid left
Example 3:
Input: board = ["OOX","XXO","OX "] Output: "Pending" Explanation: no player wins but there is still a empty grid
Note:
1 <= board.length == board[i].length <= 100