100% C++ simple
class Solution {\n    bool DidWin(vector& board, char c)\n    {\n        for(int i = 0 ; i < 3 ; i++)\n        {\n            bool all = true;\n            for(
class Solution {\n    bool DidWin(vector<string>& board, char c)\n    {\n        for(int i = 0 ; i < 3 ; i++)\n        {\n            bool all = true;\n            for(int y = 0 ; y< 3 ; y++)\n            {\n                if(board[i][y] != c)\n                {\n                    all = false;\n                    break;\n                }\n            }\n            if(all)\n                return all;\n        }\n        \n    \n        for(int i = 0 ; i < 3 ; i++)\n        {\n            bool all = true;\n            for(int y = 0 ; y< 3 ; y++)\n            {\n                if(board[y][i] != c)\n                {\n                    all = false;\n                    break;\n                }\n            }\n            if(all)\n                return all;\n        }\n        \n        bool all = true;\n        for(int i = 0 ; i< 3;i++)\n        {\n           if(board[i][i]!=c)\n           {\n               all =false;\n               break;\n           }\n        }\n        if(all)\n            return all;\n        \n        all = true;\n        int j= 0;\n        for(int i = 2 ; i >= 0 ; i--)\n        {\n           \n           if(board[j][i]!=c)\n           {\n               all =false;\n               break;\n           }\n            j++;\n        }\n        return all;\n    }\n    \npublic:\n    bool validTicTacToe(vector<string>& board) {\n        int cx=0, cy=0;\n        for(int i =0;i< 3;i++)\n        {\n            for(int y= 0 ;y< 3;y++)\n            {\n                if(board[i][y]==\'X\')\n                    cx++;\n                else if(board[i][y]==\'O\')\n                    cy ++;\n            }\n        }\n        \n        if (cy > cx|| cx > cy+1)\n            return false;\n        \n        bool winX=DidWin(board, \'X\');\n      \n        bool winY=DidWin(board, \'O\');\n      \n        if((winX && winY)|| (winY && cx != cy)|| (winX && cy != cx-1))\n            return false;\n        return true;\n        \n    }\n};
[]