SO SIMPLE I WANNA CRY (C++)
\nclass Solution {\nprivate:\n    int nx, no;\n    bool xwin, owin;\npublic:\n    Solution() : nx(0), no(0), xwin(false), owin(false)\n    {}\n    \n    bool va
```\nclass Solution {\nprivate:\n    int nx, no;\n    bool xwin, owin;\npublic:\n    Solution() : nx(0), no(0), xwin(false), owin(false)\n    {}\n    \n    bool validTicTacToe(vector<string>& board) \n    {\n        for(int i = 0; i < 3; i++)\n        {\n            for(auto c : board[i])\n            {\n                if(c == \'X\') nx++;\n                else if(c == \'O\') no++;\n            }\n        }\n        if(!(nx == no || nx == no + 1)) return false;\n        else if(nx == no)\n        {\n            return !isWin(board, \'X\');\n        }\n        else\n        {\n            return !isWin(board, \'O\');\n        }\n        return true;\n    }\n    \n    bool isWin(vector<string> &board, char c)\n    {\n        for(int i = 0; i < 3; i++)\n        {\n            if(board[i][0] == c && \\\n               board[i][0] == board[i][1] && board[i][1] == board[i][2])\n            {\n                return true;\n            }\n            else if(board[0][i] == c && \\\n                    (board[0][i] == board[1][i] && board[1][i] == board[2][i]))\n            {\n                return true;\n            }\n        }\n        if(board[0][0] == c && \\\n           board[1][1] == board[0][0] && board[2][2] == board[0][0])\n        {\n            return true;\n        }\n        else if(board[0][2] == c && \\\n           board[1][1] == board[0][2] && board[2][0] == board[0][2])\n        {\n            return true;\n        }\n        return false;\n    }\n};\n```
[]