Java solution - straightforward beats 100% with explains
\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n        \n        //countX & countO\n        int countX = 0, countO = 0;\n        for (
```\nclass Solution {\n    public boolean validTicTacToe(String[] board) {\n        \n        //countX & countO\n        int countX = 0, countO = 0;\n        for (String s : board) {\n            char[] arr = s.toCharArray();\n            for (char c : arr) {\n                if (c == \'X\') countX++;\n                else if (c == \'O\') countO++;\n            }\n        }\n        if (countX < countO || countX > countO + 1) return false;\n        \n        // check xWin or oWin\n        boolean xWin = false, oWin = false;\n        //check row & column\n        for (int i = 0; i < 3; i++) {\n            if (board[i].equals("XXX")) xWin = true;\n            if (board[i].equals("OOO")) oWin = true;\n            if (board[0].charAt(i) == \'X\' && board[1].charAt(i) == \'X\' && board[2].charAt(i) == \'X\') xWin = true;\n            if (board[0].charAt(i) == \'O\' && board[1].charAt(i) == \'O\' && board[2].charAt(i) == \'O\') oWin = true;\n        }\n        //check diagonal\n        if (!xWin) {\n            if (board[0].charAt(0) == \'X\' && board[1].charAt(1) == \'X\' && board[2].charAt(2) == \'X\') xWin = true;\n            else if (board[0].charAt(2) == \'X\' && board[1].charAt(1) == \'X\' && board[2].charAt(0) == \'X\') xWin = true;\n        }\n        if (!oWin) {\n            if (board[0].charAt(0) == \'O\' && board[1].charAt(1) == \'O\' && board[2].charAt(2) == \'O\') oWin = true;\n            else if (board[0].charAt(2) == \'O\' && board[1].charAt(1) == \'O\' && board[2].charAt(0) == \'O\') oWin = true;\n        }\n\n        if (countX == countO && xWin) return false;\n        else if (countX == countO + 1 && oWin) return false;\n        \n        return true;\n    }\n}\n\n/*\ncountX, countO\nnumber of X can be equal to number of O or countX > countO 1 element\n\nif(countX == countO) => X cannot Win\nif(countX == countO +1) => O cannot Win\n*/\n```
[]