scala solution.  (Just For Fun)
\ndef validTicTacToe(board: Array[String]): Boolean = {\n    if(board.flatten.mkString.count(_==\'X\') != board.flatten.mkString.count(_ ==\'O\') &&\n      boar
```\ndef validTicTacToe(board: Array[String]): Boolean = {\n    if(board.flatten.mkString.count(_==\'X\') != board.flatten.mkString.count(_ ==\'O\') &&\n      board.flatten.mkString.count(_==\'X\') != (board.flatten.mkString.count(_ ==\'O\') + 1)) return false\n\n    val xwin = if(board.contains("XXX")\n      || board.map(_.charAt(0)).mkString == "XXX"\n      || board.map(_.charAt(1)).mkString == "XXX"\n      || board.map(_.charAt(2)).mkString == "XXX"\n      || (board(0).charAt(0) == \'X\' && board(1).charAt(1) == \'X\'  && board(2).charAt(2) == \'X\' )\n      || (board(0).charAt(2) == \'X\' && board(1).charAt(1) == \'X\'  && board(2).charAt(0) == \'X\' )\n      )  true else false\n    val owin = if(board.contains("OOO")\n      || board.map(_.charAt(0)).mkString == "OOO"\n      || board.map(_.charAt(1)).mkString == "OOO"\n      || board.map(_.charAt(2)).mkString == "OOO"\n      || (board(0).charAt(0) == \'O\' && board(1).charAt(1) == \'O\'  && board(2).charAt(2) == \'O\' )\n      || (board(0).charAt(2) == \'O\' && board(1).charAt(1) == \'O\'  && board(2).charAt(0) == \'O\' )\n      ) true else false\n    if(xwin && owin) return false\n    if(xwin && board.flatten.mkString.count(_==\'X\') == (board.flatten.mkString.count(_==\'O\') + 1)) return true\n    if(owin && board.flatten.mkString.count(_==\'X\') == (board.flatten.mkString.count(_==\'O\'))) return true\n\n    if(!xwin && !owin && (board.flatten.mkString.count(_== \'X\') == board.flatten.mkString.count(_== \'O\')\n    ||board.flatten.mkString.count(_== \'X\') == board.flatten.mkString.count(_== \'O\') + 1)) return true\n    false\n  }\n\n```
['Scala']