Java Solution
\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n        int turns =0;\n        int[] cols=new int[3];\n        int[] rows=new int[3];\n
```\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n        int turns =0;\n        int[] cols=new int[3];\n        int[] rows=new int[3];\n        int diag=0;\n        int antidiag=0;\n        boolean xwins=false;\n        boolean owins=false;\n        \n        for(int i=0;i<3;i++)\n        {\n            for(int j=0;j<3;j++)\n            {\n                if(board[i].charAt(j)==\'X\')\n                {\n                    cols[j]++;\n                    turns++;\n                    rows[i]++;\n                    if(i == j)\n                        diag++;\n                    if(i+j == 2)\n                        antidiag++;\n                }\n                else if(board[i].charAt(j)==\'O\')\n                {\n                    cols[j]--;\n                    turns--;\n                    rows[i]--;\n                    if(i == j)\n                        diag--;\n                    if(i+j == 2)\n                        antidiag--;\n                }\n            }\n        }\n        xwins= (cols[0] == 3 || cols[1] == 3 || cols[2] == 3 ||\n                  rows[0] == 3 || rows[1] == 3 || rows[2] == 3 || diag == 3 ||\n                  antidiag == 3)? true:false;\n        owins= (cols[0] == -3 || cols[1] == -3 || cols[2] == -3 ||\n                  rows[0] == -3 || rows[1] == -3 || rows[2] == -3 || diag == -3 ||\n                  antidiag == -3)? true:false;\n        if(xwins && owins)\n            return false;\n        if(xwins && turns == 0 || owins && turns == 1)\n            return false;\n        return (turns == 1 || turns == 0);\n    }\n}\n```
[]