Simple JAVA solution
class Solution {\n    \n\tpublic boolean didXWin(String[] board){\n        for(String row : board)\n            if(row.equals("XXX"))\n                return tr
class Solution {\n    \n\tpublic boolean didXWin(String[] board){\n        for(String row : board)\n            if(row.equals("XXX"))\n                return true;\n        \n        for(int i = 0; i < 3; i++)\n            if(board[0].charAt(i) == \'X\' && board[1].charAt(i) == \'X\' && board[2].charAt(i) == \'X\')\n                return true;\n        \n        if(board[0].charAt(0) == \'X\' && board[1].charAt(1) == \'X\' && board[2].charAt(2) == \'X\')\n            return true;\n        \n        if(board[0].charAt(2) == \'X\' && board[1].charAt(1) == \'X\' && board[2].charAt(0) == \'X\')\n            return true;\n        \n        return false;\n    }\n    \n    public boolean didOWin(String[] board){\n        for(String row : board)\n            if(row.equals("OOO"))\n                return true;\n        \n        for(int i = 0; i < 3; i++)\n            if(board[0].charAt(i) == \'O\' && board[1].charAt(i) == \'O\' && board[2].charAt(i) == \'O\')\n                return true;\n        \n        if(board[0].charAt(0) == \'O\' && board[1].charAt(1) == \'O\' && board[2].charAt(2) == \'O\')\n            return true;\n        \n        if(board[0].charAt(2) == \'O\' && board[1].charAt(1) == \'O\' && board[2].charAt(0) == \'O\')\n            return true;\n        \n        return false;\n    }\n    \n    public boolean validTicTacToe(String[] board) {\n        int countX = 0, countO = 0;\n        \n        boolean didXWin = didXWin(board),\n                didOWin = didOWin(board);\n        \n        if(didXWin && didOWin)\n            return false;\n        \n        for(String row : board){\n            for(char ch : row.toCharArray()){\n                if(ch == \'O\')\n                    countO++;\n                else if(ch == \'X\')\n                    countX++;\n            }\n        }\n        \n        if(didXWin){\n            return countO == countX - 1;\n        }\n        \n        if(didOWin){\n            return countO == countX;\n        }\n        \n        return countO == countX || countO == countX - 1;\n    }\n}
['Java']