Java beat 100%
\nclass Solution {\n    char[][] bd;\n    int xc, oc;\n    public boolean validTicTacToe(String[] board) {\n        bd = parse(board);\n        xc = count(\'X\'
```\nclass Solution {\n    char[][] bd;\n    int xc, oc;\n    public boolean validTicTacToe(String[] board) {\n        bd = parse(board);\n        xc = count(\'X\');\n        oc = count(\'O\');\n        if (xc < oc || xc > oc + 1) return false;\n        boolean xw = win(\'X\'), ow = win(\'O\');\n        if(xw && ow) return false;\n        if (xw && xc == oc) return false;\n        if (ow && xc == oc + 1) return false;\n        return true;\n    }\n    \n    private char[][] parse(String[] board) {\n        char[][] res = new char[3][3];\n        for (int i = 0; i < 3; i++) {\n            String str = board[i];\n            for (int j = 0; j < 3; j++) {\n                res[i][j] = str.charAt(j);\n            }\n        }\n        return res;\n    }\n    \n    private int count(char c) {\n        int res = 0;\n        for (int i = 0; i < 3; i++) {\n            for (int j = 0; j < 3; j++) {\n                if (bd[i][j] == c) res++;\n            }\n        }\n        return res;\n    }\n    \n    private boolean win(char c) {\n        return winRow(c) || winCol(c) || winDiag(c, 1) || winDiag(c, -1);\n    }\n    \n    private boolean winRow(char c) {\n        for (int i = 0; i < 3; i++) {\n            boolean res = true;\n            for (int j = 0; j < 3; j++) {\n                if (bd[i][j] != c) {\n                    res = false;\n                    break;\n                }\n            }\n            if (res) return true;\n        }\n        return false;\n    }\n    \n    private boolean winCol(char c) {\n        for (int i = 0; i < 3; i++) {\n            boolean res = true;\n            for (int j = 0; j < 3; j++) {\n                if (bd[j][i] != c) {\n                    res = false;\n                    break;\n                }\n            }\n            if (res) return true;\n        }\n        return false;\n    }\n    \n    private boolean winDiag(char c, int dir) {\n        int j = dir == 1 ? 0 : 2;\n        for (int i = 0; i < 3; i++, j += dir){\n            if (bd[i][j] != c) {\n                return false;\n            }\n        }\n        return true;\n    }\n}\n```\n\nRef: https://leetcode.com/problems/valid-tic-tac-toe-state/discuss/318887/Java-faster-than-100-Memory-9966
[]