Python
\nclass Solution:\n    def validTicTacToe(self, board: List[str]) -> bool:\n        # Get the number of \'X\' and \'O\' in the board\n        nx, no = 0, 0\n   
```\nclass Solution:\n    def validTicTacToe(self, board: List[str]) -> bool:\n        # Get the number of \'X\' and \'O\' in the board\n        nx, no = 0, 0\n        for i in range(3):\n            for j in range(3):\n                if board[i][j] == \'O\':\n                    no += 1\n                elif board[i][j] == \'X\':\n                    nx += 1\n        \n        # Check the number difference between \'X\' and \'O\'\n        if nx != no and nx != no + 1:\n            return False\n        \n        # Check which player win\n        win_x = False\n        win_o = False\n        \n        rows = [0, 0, 0] # The sum of each row\n        cols = [0, 0, 0] # The sum of each col\n        diags = [0, 0] # The sum of two diag\n        \n        # Let empty, X, O to be 0, 1, -1\n        # Compute the sum of rows, cols, diags\n        for i in range(3):\n            for j in range(3):\n                if board[i][j] == \' \':\n                    continue\n                    \n                value = 1 if board[i][j] == \'X\' else -1\n                rows[i] += value\n                cols[j] += value\n                \n                if i == j:\n                    diags[0] += value\n                if i + j == 2:\n                    diags[1] += value\n        \n        # If X occupies a row, col or diag, then the sum should be equal to 3\n        if 3 in rows or 3 in cols or 3 in diags:\n            win_x = True\n        # If O occupies a row, col or diag, then the sum should be equal to -3\n        if -3 in rows or -3 in cols or -3 in diags:\n            win_o = True\n        \n        # Consider the following 4 cases.\n        # 1) Both win, impossible\n        # 2) 1st Player win, then X = O + 1\n        # 3) 2nd Player win, then X = O\n        # 4) Neither wins, X can be O or O + 1\n        \n        if win_x and win_o:\n            return False\n        elif win_x:\n            return nx == no + 1\n        elif win_o:\n            return nx == no\n        else:\n            # We have already ensured X == O or O + 1 in the beginning\n            return True\n```
[]