Simple Easy and Clean Code
\nclass Solution {\npublic:\n    bool validTicTacToe(vector<string>& board) {\n        int xcount,ocount;\n        xcount=ocount=0;\n        int xwin,owin;\n   
```\nclass Solution {\npublic:\n    bool validTicTacToe(vector<string>& board) {\n        int xcount,ocount;\n        xcount=ocount=0;\n        int xwin,owin;\n        xwin=owin=0;\n        for(int i=0;i<board.size();i++){\n            for(int j=0;j<3;j++){\n                if(board[i][j]==\'X\')    xcount++;\n                if(board[i][j]==\'O\')    ocount++;\n            }\n            if(board[i][1]==board[i][0] and board[i][2]==board[i][1] and board[i][1]!=\' \'){\n                if(board[i][1]==\'X\')    xwin++;\n                if(board[i][1]==\'O\')    owin++;\n            }\n            if(board[1][i]==board[0][i] and board[2][i]==board[1][i] and board[1][i]!=\' \'){\n                if(board[1][i]==\'X\')    xwin++;\n                if(board[1][i]==\'O\')    owin++;\n            }\n        }\n        if(board[1][1]==board[0][0] and board[2][2]==board[1][1] and board[1][1]!=\' \'){\n                if(board[1][1]==\'X\')    xwin++;\n                if(board[1][1]==\'O\')    owin++;\n        }\n        if(board[0][2]==board[2][0] and board[2][0]==board[1][1] and board[1][1]!=\' \'){\n                if(board[1][1]==\'X\')    xwin++;\n                if(board[1][1]==\'O\')    owin++;\n        }\n        if(abs(xcount-ocount)>1 or ocount>xcount or (xwin>0 and owin>0))\n            return false;\n        if(xwin>0){\n            return(xcount>ocount);\n        }\n        if(owin>0){\n            return (ocount==xcount);\n        }\n        return true;\n    }\n};\n```
[]