concise code beat 100% python solution with explanation
There is only four situation that Tic-Tac-Toe is invalid:\n1. two players are not taking turns making move\n2. "O" player makes move before "X" player\n3. "X" p
There is only four situation that Tic-Tac-Toe is invalid:\n1. two players are not taking turns making move\n2. "O" player makes move before "X" player\n3. "X" player wins but "O" player continues to make move\n4. "O" player wins but "X" player continues to make move\n\n```\nclass Solution(object):\n    def validTicTacToe(self, board):\n        def win(s): # return True if the player who use s wins\n            if board[0][0]==s and board[0][1]==s and board[0][2]==s: return True\n            if board[1][0]==s and board[1][1]==s and board[1][2]==s: return True\n            if board[2][0]==s and board[2][1]==s and board[2][2]==s: return True\n            if board[0][0]==s and board[1][0]==s and board[2][0]==s: return True\n            if board[0][1]==s and board[1][1]==s and board[2][1]==s: return True\n            if board[0][2]==s and board[1][2]==s and board[2][2]==s: return True\n            if board[0][0]==s and board[1][1]==s and board[2][2]==s: return True\n            if board[0][2]==s and board[1][1]==s and board[2][0]==s: return True\n            return False\n        \n        xNo, oNo=0, 0\n        for row in board:\n            xNo+=row.count(\'X\')\n            oNo+=row.count(\'O\')\n        if oNo>xNo or xNo-oNo>=2: # "X" not making move first or not taking turns making move\n            return False\n        if xNo>=3:\n            if xNo==oNo and win(\'X\'): # put another "O" after "X" player winning\n                return False\n            if xNo!=oNo and win(\'O\'): # put another "X" after "O" player winning\n                return False\n        return True\n```\n![image](https://assets.leetcode.com/users/ytp27/image_1578954871.png)\n
['Python', 'Python3']