Python | Easy to understand
\nclass Solution(object):\n    def validTicTacToe(self, board):\n        """\n        :type board: List[str]\n        :rtype: bool\n        """\n               
```\nclass Solution(object):\n    def validTicTacToe(self, board):\n        """\n        :type board: List[str]\n        :rtype: bool\n        """\n                \n        countX = 0\n        countO = 0\n        \n        rows = [0] * 3\n        cols = [0] * 3\n        diag = [0] * 3\n                \n        for i in range(3):\n            for j in range(3):\n                if board[i][j] == \'X\':\n                    rows[i] += 1\n                    cols[j] += 1\n                    countX += 1\n                    if i == j:\n                        diag[0] += 1\n                    if i + j == 2:\n                        diag[1] += 1\n                \n                if board[i][j] == \'O\':\n                    rows[i] -= 1\n                    cols[j] -= 1\n                    countO += 1\n                    if i == j:\n                        diag[0] -= 1\n                    if i + j == 2:\n                        diag[1] -= 1\n                \n        maxVal = max(max(rows),max(cols),max(diag))\n        minVal = min(min(rows),min(cols),min(diag))\n\n        ## Case 1: count not good\n        if (countX < countO) or (countX - countO > 1):\n            return False\n        \n        ## Case 2: have both winning cases\n        if maxVal == 3 and minVal == -3:\n            return False\n        \n        ## Case 3: have X win but countO == countX\n        if maxVal == 3 and (countX == countO):\n            return False\n        \n        ## Case 4: have O win but countO < countX\n        if minVal == -3 and (countX > countO):\n            return False\n\n        return True\n        \n\n```
[]