/
githubmirror
/
LeetCodeAnimation
Обзор
Документация
Войти
/
githubmirror
/
LeetCodeAnimation
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
problems/0036-valid-sudoku/Code/1.java
34 строки
1 KB
吴至波
docs: organize assets and add animation previews
10 июн 2026, 10:57
10 июн 2026, 10:57
3711846
Код
Авторство
О чём код?
class Solution { public boolean isValidSudoku(char[][] board) { HashMap[] row = new HashMap[9]; HashMap[] column = new HashMap[9]; HashMap[] box = new HashMap[9]; for (int i = 0; i < 9; i++) { row[i] = new HashMap(9); column[i] = new HashMap(9); box[i] = new HashMap(9); } for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { if (board[i][j] == '.') { continue; } int boxIndex=i / 3 * 3 + j / 3; if ((boolean) row[i].getOrDefault(board[i][j], true)) { return false; } if ((boolean) column[j].getOrDefault(board[i][j], true)) { return false; } if ((boolean) box[boxIndex].getOrDefault(board[i][j], true)) { return false; } row[i].put(board[i][j], false); column[j].put(board[i][j], false); box[boxIndex].put(board[i][j], false); } } return true; } }