/** * @param {character[][]} board * @return {boolean} */ var isValidSudoku = function (board) { returncheck3x3() && checkCol() && checkRow();

functioncheck3x3() { let set = newSet(); let times = 0; for (let r = 0; r <= 8; r += 3) { for (let c = 0; c <= 8; c += 3) { for (let i = r; i <= r + 2; i++) { for (let j = c; j <= c + 2; j++) { if (!isNaN(board[i][j])) { set.add(board[i][j] - 0); times++; } } } if (times !== set.size) returnfalse; times = 0; set.clear(); } } return set.size === times; } functioncheckRow() { let set = newSet(); let times = 0; for (let i = 0; i <= 8; i++) { for (let j = 0; j <= 8; j++) { if (!isNaN(board[i][j])) { set.add(board[i][j] - 0); times++; } } if (times !== set.size) returnfalse; times = 0; set.clear(); } return times === set.size; } functioncheckCol() { let set = newSet(); let times = 0; for (let j = 0; j <= 8; j++) { for (let i = 0; i <= 8; i++) { if (!isNaN(board[i][j])) { set.add(board[i][j] - 0); times++; } } if (times !== set.size) returnfalse; times = 0; set.clear(); } returntrue; } };