Straightforward Java solution with explaination
When turns is 1, X moved. When turns is 0, O moved. rows stores the number of X or O in each row. cols stores the number of X or O in each column. diag stores t
When `turns` is 1, X moved. When `turns` is 0, O moved. `rows` stores the number of X or O in each row. `cols` stores the number of X or O in each column. `diag` stores the number of X or O in diagonal. `antidiag` stores the number of X or O in antidiagonal. When any of the value gets to 3, it means X wins. When any of the value gets to -3, it means O wins.\n\nWhen X wins, O cannot move anymore, so `turns` must be 1. When O wins, X cannot move anymore, so `turns` must be 0. Finally, when we return, `turns` must be either 0 or 1, and X and O cannot win at same time.\n```\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n        int turns = 0;\n        boolean xwin = false; \n        boolean owin = false;\n        int[] rows = new int[3];\n        int[] cols = new int[3];\n        int diag = 0;\n        int antidiag = 0;\n\t\t\t\t\n        for (int i = 0; i < 3; i++) {\n            for (int j = 0; j < 3; j++) {\n                if (board[i].charAt(j) == \'X\') {\n                    turns++; rows[i]++; cols[j]++;\n                    if (i == j) diag++;\n                    if (i + j == 2) antidiag++;\n                } else if (board[i].charAt(j) == \'O\') {\n                    turns--; rows[i]--; cols[j]--;\n                    if (i == j) diag--;\n                    if (i + j == 2) antidiag--;\n                }\n            }\n        }\n\t\t\n        xwin = rows[0] == 3 || rows[1] == 3 || rows[2] == 3 || \n               cols[0] == 3 || cols[1] == 3 || cols[2] == 3 || \n               diag == 3 || antidiag == 3;\n        owin = rows[0] == -3 || rows[1] == -3 || rows[2] == -3 || \n               cols[0] == -3 || cols[1] == -3 || cols[2] == -3 || \n               diag == -3 || antidiag == -3;\n        \n        if (xwin && turns == 0 || owin && turns == 1) {\n            return false;\n        }\n        return (turns == 0 || turns == 1) && (!xwin || !owin);\n    }\n}\n```
[]