a few solutions
There are 4 use cases to consider:\n\n Case 1: if X won and O won, then return false since there cannot be more than one winner\n Case 2: if X won, then return 
There are 4 use cases to consider:\n\n* **Case 1:** if `X` won and `O` won, then return `false` since there cannot be more than one winner\n* **Case 2:** if `X` won, then return `true` if and only if there exists one more `X` than `O`\n* **Case 3:** if `O` won, then return `true` if and only if there exists the same amount `X` and `O`\n* **Case 4:** if no winner, then return `true` if and only if there exists either one more `X` than `O` xor the same amount `X` and `O`\n\n---\n\n*Javascript*\n```\nlet validTicTacToe = A => {\n    let X = _.sum(A.map(row => row.split(\'\').filter(c => c == \'X\').length)),\n        O = _.sum(A.map(row => row.split(\'\').filter(c => c == \'O\').length));\n    let win = c => {\n        let target = c.repeat(3);\n        if (A.some(row => row == target))\n            return true;\n        for (let j = 0; j < 3; ++j) {\n            let col = A[0][j] + A[1][j] + A[2][j];\n            if (col == target)\n                return true;\n        }\n        return A[0][0] + A[1][1] + A[2][2] == target || A[0][2] + A[1][1] + A[2][0] == target;\n    };\n    let winX = win(\'X\'),\n        winO = win(\'O\');\n    if (winX && winO)       return false;  // case 1: if X won and O won\n    if (winX && X - O != 1) return false;  // case 2: if X won, then there must be one more X than O\n    if (winO && X - O != 0) return false;  // case 3: if O won, then there must be the same amount of X and O\n    return X - O == 0 || X - O == 1;       // case 4: if no winner, then there must be the same amount of X and O xor one more X than O\n};\n```\n\n*Python3*\n```\nclass Solution:\n    def validTicTacToe(self, A: List[str], winX = False, winO = False) -> bool:\n        X = sum([row.count(\'X\') for row in A])\n        O = sum([row.count(\'O\') for row in A])\n        def win(c):\n            target = c * 3\n            for row in A:\n                if row == target: return True\n            for j in range(3):\n                col = A[0][j] + A[1][j] + A[2][j]\n                if col == target: return True\n            return A[0][0] + A[1][1] + A[2][2] == target or A[0][2] + A[1][1] + A[2][0] == target\n        winX = win(\'X\')\n        winO = win(\'O\')\n        if winX and winO:       return False  # case 1: if X won and O won\n        if winX and X - O != 1: return False  # case 2: if X won, then there must be one more X than O\n        if winO and X - O != 0: return False  # case 3: if O won, then there must be the same amount of X and O\n        return X - O in [0, 1]                # case 4: if no winner, then there must be the same amount of X and O xor one more X than O\n```\n\n*C++*\n```\nclass Solution {\npublic:\n    using VS = vector<string>;\n    bool validTicTacToe(VS& A, string S = {}) {\n        for (auto& row: A)\n            S.append(row);\n        int X = count_if(S.begin(), S.end(), [](auto c) { return c == \'X\'; }),\n            O = count_if(S.begin(), S.end(), [](auto c) { return c == \'O\'; });\n        auto win = [&](auto c) {\n            auto target = string(3, c);\n            if (any_of(A.begin(), A.end(), [&](auto& row) { return row == target; }))\n                return true;\n            for (auto j{ 0 }; j < 3; ++j) {\n                stringstream col; col << A[0][j] << A[1][j] << A[2][j];\n                if (col.str() == target)\n                    return true;\n            }\n            stringstream diag1; diag1 << A[0][0] << A[1][1] << A[2][2];\n            stringstream diag2; diag2 << A[0][2] << A[1][1] << A[2][0];\n            return diag1.str() == target || diag2.str() == target;\n        };\n        auto winX = win(\'X\'),\n             winO = win(\'O\');\n        if (winX && winO)       return false;  // case 1: if X won and O won\n        if (winX && X - O != 1) return false;  // case 2: if X won, then there must be one more X than O\n        if (winO && X - O != 0) return false;  // case 3: if O won, then there must be the same amount of X and O\n        return X - O == 0 || X - O == 1;       // case 4: if no winner, then there must be the same amount of X and O xor one more X than O\n    }\n};\n```
[]