100% C++ easy to understand. :D
\n#include <bits/stdc++.h>\n#include <stdio.h>\nusing namespace std;\n\nvector<vector<pair<int, int>>> possibleSolutions{\n    {{0, 0}, {0, 1}, {0, 2}}, //first
```\n#include <bits/stdc++.h>\n#include <stdio.h>\nusing namespace std;\n\nvector<vector<pair<int, int>>> possibleSolutions{\n    {{0, 0}, {0, 1}, {0, 2}}, //first row\n    {{1, 0}, {1, 1}, {1, 2}},\n    {{2, 0}, {2, 1}, {2, 2}},\n    {{0, 0}, {1, 0}, {2, 0}}, // first col\n    {{0, 1}, {1, 1}, {2, 1}},\n    {{0, 2}, {1, 2}, {2, 2}},\n    {{0, 0}, {1, 1}, {2, 2}}, //first diagonal\n    {{0, 2}, {1, 1}, {2, 0}}  // second diagonal\n\n};\n// This function checks if the particular character is winning or not atleast once\nint isValidCombination(vector<string> &board, char ch)\n{\n    for (auto x : possibleSolutions)\n    {\n        auto curr = x;\n        auto cord1 = x[0];\n        auto cord2 = x[1];\n        auto cord3 = x[2];\n\n        if (board[cord1.first][cord1.second] == ch and board[cord2.first][cord2.second] == ch and board[cord3.first][cord3.second] == ch)\n        {\n            return 1;\n        }\n    }\n    return 0;\n}\n\nclass Solution\n{\npublic:\n    bool validTicTacToe(vector<string> &board)\n    {\n        int countX = 0;\n        int countO = 0;\n\n        for (auto x : board)\n        {\n            for (auto c : x)\n            {\n                if (c == \'X\')\n                {\n                    countX++;\n                }\n                else if(c == \'O\')\n                {\n                    countO++;\n                }\n            }\n        }\n        // cout<<countX<<" "<<countO<<endl;\n\n        if ((countX == countO) or (countX == countO + 1))\n        {\n            int isXwinning = isValidCombination(board, \'X\');\n            int isOwinning = isValidCombination(board, \'O\');\n\n            if (isXwinning)\n            {\n                if (isOwinning)\n                {\n                    return 0;\n                }\n                return countX == countO + 1;\n            }\n            if (isOwinning)\n            {\n                if (isXwinning)\n                {\n                    return 0;\n                }\n                return countX == countO;\n            }\n            return 1;\n        }\n        else\n        {\n            return 0;\n        }\n    }\n};\n\n```
[]