Java - 20 lines with a cute trick.
Note - Code updated to fix a failed testcase, thanks nkallen for pointing it out.\n\nThe idea is simple.\nStep 1 -  get a count of the \'X\' and \'O\'.\nStep 2 
**Note** - Code updated to fix a failed testcase, thanks nkallen for pointing it out.\n\nThe idea is simple.\n**Step 1** -  get a count of the \'X\' and \'O\'.\n**Step 2** (optional) - Now we can exlude any state with X < O or X > O+1. (we could fold this into the last return statement but that would be quite unreadable.)\n**Step 3** - Look at all possible 3-Rows (There is 8 of them), if we find 3x \'X\' increment a counter by 1, if we find 3x \'O\' decrement a counter by some number greater than 8 (here -10 is used).\n**Step 4** - If the counter is 0 noone won, if the counter is 1 OR 2 \'X\' won and the state is legal if x has one more piece, if the counter is -10 \'O\' won exactly once and the state is legal if the num pieces is equal, if the counter is anything else then the state is illegal.\n\n\n``` \npublic boolean validTicTacToe(String[] board) {\n    int xCount = 0, oCount = 0;\n    char[] arr = (board[0] + board[1] + board[2]).toCharArray();\n    for (char c : arr) {\n        if (c == \'O\') oCount++;\n        if (c == \'X\') xCount++;\n    }\n    if (oCount != xCount && oCount+1 != xCount)\n        return false;\n    int winState = getWinState(arr[0], arr[4], arr[8]);\n       winState += getWinState(arr[6], arr[4], arr[2]);\n    for (int i = 0; i < 3; i++) {\n        winState += getWinState(arr[i*3], arr[i*3+1], arr[i*3+2]);\n        winState += getWinState(arr[i], arr[i+3], arr[i+6]);\n    }\n    return winState == 0 || (winState == -10 && oCount == xCount) || ((winState == 1 || winState == 2) && oCount+1 == xCount);\n}\nprivate int getWinState(char c1, char c2, char c3) {\n    if (c1 != \' \' && c1 == c2 && c2 == c3) return c1 == \'X\' ? 1 : -10;\n    else return 0;\n} \n``` \n------------\nFor fun here is the same solution with a little bit more complicated logic but a few less lines of code:\n\n``` \npublic boolean validTicTacToe(String[] board) {\n    int xCount = 0, oCount = 0;\n    char[] arr = (board[0] + board[1] + board[2]).toCharArray();\n    for (char c : arr) {\n        if (c == \'O\') oCount++;\n        if (c == \'X\') xCount++;\n    }\n    int winState = getWinState(arr[0], arr[4], arr[8]);\n       winState += getWinState(arr[6], arr[4], arr[2]);\n    for (int i = 0; i < 3; i++) {\n        winState += getWinState(arr[i*3], arr[i*3+1], arr[i*3+2]);\n        winState += getWinState(arr[i], arr[i+3], arr[i+6]);\n    }\n    return (winState%10 == 0 && oCount == xCount) || (winState < 3 && oCount+1 == xCount);\n}\nprivate int getWinState(char c1, char c2, char c3) {\n    if (c1 != \' \' && c1 == c2 && c2 == c3) return c1 == \'X\' ? 1 : 10;\n    else return 0;\n}
[]