[Python/C++/Java] 17 lines straightforward solution / std::any, std::count
The code explains itself :)\n\nPython\n\npython\nclass Solution:\n    def validTicTacToe(self, board: List[str]) -> bool:\n        def isWin(c: chr) -> bool:\n 
The code explains itself :)\n\n**Python**\n\n```python\nclass Solution:\n    def validTicTacToe(self, board: List[str]) -> bool:\n        def isWin(c: chr) -> bool:\n            return any(row.count(c) == 3 for row in board) or \\\n                any(row.count(c) == 3 for row in list(zip(*board))) or \\\n                all(board[i][i] == c for i in range(3)) or \\\n                all(board[i][2 - i] == c for i in range(3))\n\n        countX = sum(row.count(\'X\') for row in board)\n        countO = sum(row.count(\'O\') for row in board)\n\n        if countX < countO or countX - countO > 1:\n            return False\n        if isWin(\'X\') and countX == countO or isWin(\'O\') and countX != countO:\n            return False\n\n        return True\n```\n\n**C++**\n\n```cpp\nclass Solution {\n public:\n  bool validTicTacToe(vector<string>& board) {\n    int countX = sum(board, \'X\');\n    int countO = sum(board, \'O\');\n\n    if (countX < countO || countX - countO > 1) return false;\n    if (isWinned(board, \'X\') && countX == countO ||\n        isWinned(board, \'O\') && countX != countO)\n      return false;\n\n    return true;\n  }\n\n private:\n  int sum(const vector<string>& board, char c) {\n    int ans = 0;\n\n    for (const string& row : board) ans += count(begin(row), end(row), c);\n\n    return ans;\n  }\n\n  bool isWinned(const vector<string>& board, char c) {\n    vector<string> rotated = rotate(board);\n\n    auto equalsToThree = [&c](const string& row) {\n      return count(begin(row), end(row), c) == 3;\n    };\n\n    return any_of(begin(board), end(board), equalsToThree) ||\n           any_of(begin(rotated), end(rotated), equalsToThree) ||\n           board[0][0] == c && board[1][1] == c && board[2][2] == c ||\n           board[0][2] == c && board[1][1] == c && board[2][0] == c;\n  }\n\n  vector<string> rotate(const vector<string>& board) {\n    vector<string> rotated(3);\n\n    for (const string& row : board)\n      for (int i = 0; i < 3; ++i) rotated[i].push_back(row[i]);\n\n    return rotated;\n  }\n};\n```\n\n**Java**\n\n```java\nclass Solution {\n  public boolean validTicTacToe(String[] board) {\n    int countX = sum(board, \'X\');\n    int countO = sum(board, \'O\');\n\n    if (countX < countO || countX - countO > 1)\n      return false;\n    if (isWinned(board, \'X\') && countX == countO || isWinned(board, \'O\') && countX != countO)\n      return false;\n\n    return true;\n  }\n\n  private int sum(final String[] board, char c) {\n    int ans = 0;\n\n    for (final String row : board)\n      ans += row.chars().filter(i -> i == c).count();\n\n    return ans;\n  }\n\n  private boolean isWinned(final String[] board, char c) {\n    String[] rotated = rotate(board);\n\n    return Arrays.stream(board).anyMatch(row -> row.chars().filter(i -> i == c).count() == 3)\n        || Arrays.stream(rotated).anyMatch(row -> row.chars().filter(i -> i == c).count() == 3)\n        || board[0].charAt(0) == c && board[1].charAt(1) == c && board[2].charAt(2) == c\n        || board[0].charAt(2) == c && board[1].charAt(1) == c && board[2].charAt(0) == c;\n  }\n\n  private String[] rotate(final String[] board) {\n    String[] rotated = new String[3];\n\n    for (final String row : board)\n      for (int i = 0; i < 3; ++i)\n        rotated[i] += row.charAt(i);\n\n    return rotated;\n  }\n}\n```
['Python']