0ms 100% faster with SIMPLE LOGIC and Explanation also short than others
\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n       \n        int cO=0, cX=0;\n        for(int x=0; x<3; x++){\n            for(int 
```\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n       \n        int cO=0, cX=0;\n        for(int x=0; x<3; x++){\n            for(int y=0; y<3; y++){\n                char ch=board[x].charAt(y);\n                if(ch == \'O\')\n                    cO++;\n                else if(ch == \'X\')\n                    cX++;                \n            }\n        }  \n        char a1=board[0].charAt(0);\n        char a2=board[0].charAt(1);\n        char a3=board[0].charAt(2);\n        char a4=board[1].charAt(0);\n        char a5=board[1].charAt(1);\n        char a6=board[1].charAt(2);\n        char a7=board[2].charAt(0);\n        char a8=board[2].charAt(1);\n        char a9=board[2].charAt(2);\n        \n        //The main thing here is we just need to check if the given sequence is possible or not.\n        //We dont need to find any winner. *Logic is the one who has last chance can be in 1 row, column(horizontally,vertically or diagonally) not the other one.\n        //So few cases will arise \n        //1) Count of \'X\' is 1 more than count of \'O\'-> Only X can win and \'O\' cannot win (Last Chance is with X so only X can win)\n        //2) Count of \'X\' is equal to count of \'O\'   -> Only \'O\' can win and \'X\' cannot win(Check few cases)(Last Chance is with \'O\' so only \'O\' can win)\n        //3) return false (rest all are invalid case)\n        \n        \n        // Eg - if X=4 and O=3 (ie Count of \'O\' is 1 less) then \'O\' cannot win and \n        //if we find such a case then we need to return false else the sequence is fine(try yourself & see) \n         if( (cX-1) == cO ){\n             if( (a1==a2 && a2==a3 && a1==\'O\')||    //These are all horizaontal, vertical, diagonal \n                (a4==a5 && a5==a6 && a4==\'O\')||     //positions to check\n                (a7==a8 && a8==a9 && a7==\'O\')||\n                (a1==a5 && a5==a9 && a1==\'O\')||\n                (a3==a5 && a5==a7 && a3==\'O\')||\n                (a1==a4 && a4==a7 && a1==\'O\')||\n                (a2==a5 && a5==a8 && a2==\'O\')||\n                (a3==a6 && a6==a9 && a3==\'O\') )\n                return false;\n             else\n                 return true;\n         }\n        //if X=4 and O=4 (ie both r equal) then \'X\' cannot win amd\n        //if we find such a case then we need to return false else the sequence is fine(try yourself & see)\n        else if(cX==cO){            \n            if( (a1==a2 && a2==a3 && a1==\'X\')||\n                (a4==a5 && a5==a6 && a4==\'X\')||\n                (a7==a8 && a8==a9 && a7==\'X\')||\n                (a1==a5 && a5==a9 && a1==\'X\')||\n                (a3==a5 && a5==a7 && a3==\'X\')||\n                (a1==a4 && a4==a7 && a1==\'X\')||\n                (a2==a5 && a5==a8 && a2==\'X\')||\n                (a3==a6 && a6==a9 && a3==\'X\') )\n                return false;\n            else\n                return true;\n        }          \n        return false;\n    }\n}\n```\nPlease UPVOTE
['Java']