Very easy Solution just count the number of 'X' and 'O'
\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n        \n        \n        int cx=0,co=0,wonx=0,wono=0;\n        \n        char[][] ar
```\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n        \n        \n        int cx=0,co=0,wonx=0,wono=0;\n        \n        char[][] arr = new char[3][3];\n        \n        for(int i =0; i<board.length; i++)\n        {\n            String temp = board[i];\n            if(temp.equals("XXX"))        //checking if X is winner in rows\n                wonx = 1;\n            if(temp.equals("OOO"))      // checking if O is winner in rows\n                wono = 1;\n            \n            for(int j=0; j<temp.length(); j++)\n            {\n                arr[i][j] = temp.charAt(j);\n                if(temp.charAt(j)==\'X\')\n                    cx++;                         // counting no. of X\n                else if(temp.charAt(j)==\'O\')\n                    co++;                        // counting no. of O\n                \n            }\n        }\n        \n        for(int i=0; i<3; i++)\n        {\n            if(arr[0][i]==\'X\' && arr[1][i]==\'X\' && arr[2][i]==\'X\')    //checking if X is winner in columns\n                wonx = 1;\n            if(arr[0][i]==\'O\' && arr[1][i]==\'O\' && arr[2][i]==\'O\')   //checking if O is winner in columns\n                wono = 1;\n            \n            \n        }\n        if(arr[0][0]==\'X\' && arr[1][1]==\'X\' && arr[2][2]==\'X\')   //checking if X is winner \'\\\' in diogonal\n            wonx=1;\n        \n        if(arr[0][0]==\'O\' && arr[1][1]==\'O\' && arr[2][2]==\'O\')  // checking if O is winner \'\\\' in diogonal\n            wono=1;\n        \n        if(arr[0][2]==\'X\' && arr[1][1]==\'X\' && arr[2][0]==\'X\' )    //checking if X is winner \'/\' in diogonal\n            wonx=1;\n        \n        if(arr[0][2]==\'O\' && arr[1][1]==\'O\' && arr[2][0]==\'O\' )   //checking if O is winner \'/\' in diogonal\n            wono=1;\n        \n        \n        if((wonx==1 && wono==1))   //both X and O can\'t win\n            return false;\n        \n        if(cx - co > 1  || cx - co < 0)     //there count can\'t cross [0,1] range coz they mark X and O one by one\n            return false;\n        \n        if((wonx==1 && wono==0) && cx - co==1)  //if X won  cx - co can\'t exceed 1 coz X goes first and and after winning game should stop\n            return true;\n        \n        if((wono==1 && wonx==0)  && cx==co)    //if O won  cx - co can\'t exceed 0 coz X goes first and and after winning game should stop\n            return true;\n        \n        if((wonx==0 && wono ==0) && ((cx - co==0) || (cx - co ==1)) )  // if none of them won just take care of their moves i.e. they took their chances one by one\n            return true;\n        \n        \n        return false;\n        \n    }\n}\n```
[]