C++ | Easy Understandable Solution
Please upvote if you like the solution\n\nclass Solution {\npublic:\n    bool validTicTacToe(vector<string>& board) {\n        int countx=0,counto=0,blank=0;  /
Please upvote if you like the solution\n```\nclass Solution {\npublic:\n    bool validTicTacToe(vector<string>& board) {\n        int countx=0,counto=0,blank=0;  //count of \'X\',\'O\',and \' \'....\n        bool xwin=false,owin=false;   //X,O won or not... \n        int xwon=0,owon=0;   // no. of winnings of O and X...\n        for(int i=0;i<3;i++)\n        {\n            for(int j=0;j<3;j++)\n            {\n                if(board[i][j]==\'X\') countx++;      //count of X...\n                else if(board[i][j]==\'O\') counto++;     //count of O...\n                else if(board[i][j]==\' \') blank++;    //count of \'space\'...\n            }\n        }          //conditions to check X\'s Winning State....\n        if(board[0][0]==\'X\'&&board[0][1]==\'X\'&&board[0][2]==\'X\') {xwon++; xwin=true;}\n        if(board[1][0]==\'X\'&&board[1][1]==\'X\'&&board[1][2]==\'X\') {xwon++; xwin=true;}\n        if(board[2][0]==\'X\'&&board[2][1]==\'X\'&&board[2][2]==\'X\') {xwon++; xwin=true;}\n        if(board[0][0]==\'X\'&&board[1][0]==\'X\'&&board[2][0]==\'X\') {xwon++; xwin=true;}\n        if(board[0][1]==\'X\'&&board[1][1]==\'X\'&&board[2][1]==\'X\') {xwon++; xwin=true;}\n        if(board[0][2]==\'X\'&&board[1][2]==\'X\'&&board[2][2]==\'X\') {xwon++; xwin=true;}\n        if(board[0][0]==\'X\'&&board[1][1]==\'X\'&&board[2][2]==\'X\') {xwon++; xwin=true;}\n        if(board[0][2]==\'X\'&&board[1][1]==\'X\'&&board[2][0]==\'X\') {xwon++; xwin=true;}\n        //Conditions to Check O\'s Winning State...\n        if(board[0][0]==\'O\'&&board[0][1]==\'O\'&&board[0][2]==\'O\') {owon++; owin=true;}\n        if(board[1][0]==\'O\'&&board[1][1]==\'O\'&&board[1][2]==\'O\') {owon++; owin=true;}\n        if(board[2][0]==\'O\'&&board[2][1]==\'O\'&&board[2][2]==\'O\') {owon++; owin=true;}\n        if(board[0][0]==\'O\'&&board[1][0]==\'O\'&&board[2][0]==\'O\') {owon++; owin=true;}\n        if(board[0][1]==\'O\'&&board[1][1]==\'O\'&&board[2][1]==\'O\') {owon++; owin=true;}\n        if(board[0][2]==\'O\'&&board[1][2]==\'O\'&&board[2][2]==\'O\') {owon++; owin=true;}\n        if(board[0][0]==\'O\'&&board[1][1]==\'O\'&&board[2][2]==\'O\') {owon++; owin=true;}\n        if(board[0][2]==\'O\'&&board[1][1]==\'O\'&&board[2][0]==\'O\') {owon++; owin=true;}\n        //Conditions Which can\'t happen in a Real Game....\n        if(owon>1||xwon>2||abs(countx-counto)>1||(counto-countx)>0||(owin==true&&xwin==true)||(blank%2==0&&countx<=counto)||(blank%2!=0&&countx!=counto)||(xwin&&countx<=counto)||(owin&&countx!=counto))\n        {\n            return false;\n        }\n        else\n        {\n            return true;\n        }\n    }\n};\n```
['C']