Determine if a 9 x 9
Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
1-9
without repetition.1-9
without repetition.3 x 3
sub-boxes of the grid must contain the digits 1-9
without repetition.Note:
function solution(board: string[][]) {
for (let i = 0; i < 9; i ++) {
for (let j = 0; j < 9; j ++) {
if (board[i][j] === '.') continue;
for (let right = j + 1; right < 9; right ++) {
if (board[i][j] === board[i][right]) {
return false;
}
}
for (let bottom = i + 1; bottom < 9; bottom ++) {
if (board[i][j] === board[bottom][j]) {
return false;
}
}
// 같은 칸에 있는지 확인
}
}
return true;
}
같은 칸에 있는지 체크 못했음..