Java 0ms concise solution | easy understand
\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n        // count the turns of each player\n        int[] count = new int[3];\n        b
```\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n        // count the turns of each player\n        int[] count = new int[3];\n        boolean xWins = false;\n        boolean oWins = false;\n        \n        for (String s : board){\n            //check each row\n            if (s.equals("XXX")) xWins = true;\n            if (s.equals("OOO")) oWins = true;\n            for (int i = 0; i < s.length(); i++){\n                char cur = s.charAt(i);\n                if (cur == \' \') count[0]++;\n                else if (cur == \'X\') count[1]++;\n                else count[2]++;\n            }\n        }\n        int diff = count[1] - count[2]; \n        if (diff < 0 || diff > 1) return false;\n        \n        // check each colomn\n        for (int i = 0; i < 3; i++){\n            if (board[0].charAt(i) == board[1].charAt(i) && board[1].charAt(i) == board[2].charAt(i)){\n                if (board[0].charAt(i) == \'X\') xWins = true;\n                if (board[0].charAt(i) == \'O\') oWins = true;\n            }\n        }\n        //check diagonal\n        if (board[0].charAt(0) == board[1].charAt(1) && board[1].charAt(1) == board[2].charAt(2)){\n            if (board[0].charAt(0) == \'X\') xWins = true;\n            if (board[0].charAt(0) == \'O\') oWins = true;\n        }\n        //check antidiagonal\n        if (board[0].charAt(2) == board[1].charAt(1) && board[1].charAt(1) == board[2].charAt(0)){\n            if (board[1].charAt(1) == \'X\') xWins = true;\n            if (board[1].charAt(1) == \'O\') oWins = true;\n        }\n        // if X wins, turns difference between two player must be 1; \n        // if O wins, turns difference between two player must be 0;\n        if ( xWins && diff != 1) return false;\n        if ( oWins && diff != 0) return false;\n\n        return true;      \n    }\n}\n```
[]