Elegant Python Solution
\nclass Solution:\n    def validTicTacToe(self, board: List[str]) -> bool:\n        \n        board = \'\'.join(board)\n        \n        counter = Counter(boar
```\nclass Solution:\n    def validTicTacToe(self, board: List[str]) -> bool:\n        \n        board = \'\'.join(board)\n        \n        counter = Counter(board)\n        \n        def win(player, board):\n            condition = player * 3    \n            # horizontal\n            for i in [0,3,6]:\n                if condition == board[i:i+3]:\n                    return True\n            # vertical\n            for i in [0,1,2]:\n                if condition == board[i:i+7:3]:\n                    return True\n            # diagonal\n            if condition in [board[::4], board[2:7:2]]:\n                return True\n            \n            return False\n        \n        # X must not win in this case\n        if counter[\'X\'] == counter[\'O\']:\n            return not win(\'X\', board)\n        # O must not win in this case\n        elif counter[\'X\'] == counter[\'O\'] + 1:\n            return not win(\'O\', board)\n                \n        return False\n        \n```
[]