1
var validTicTacToe = function (board) {4
let horizontal = [0, 0, 0];5
let vertical = [0, 0, 0];8
const transformConfig = (row, col, val) => {9
horizontal[row] += val;13
if (row + col == board.length - 1) {16
} else if (row + col == board.length - 1) {21
board.forEach((data, row) => {22
data.split("").forEach((turn, col) => {25
transformConfig(row, col, 1);26
} else if (turn == "O") {28
transformConfig(row, col, -1);32
if (playerX < playerO || playerX - playerO > 1) return false;33
if (horizontal.includes(3) && playerX <= playerO) return false;34
if (vertical.includes(3) && playerX <= playerO) return false;35
if (diagnol.includes(3) && playerX <= playerO) return false;36
if (horizontal.includes(-3) && playerX > playerO) return false;37
if (vertical.includes(-3) && playerX > playerO) return false;38
if (diagnol.includes(-3) && playerX > playerO) return false;