-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Bug Report for https://neetcode.io/problems/valid-sudoku
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
an error is rising for import even though there is no error here is my code:
import java.util.*;
class Solution {
public boolean isValidSudoku(char[][] board) {
Set[] rows = new HashSet[9];
Set[] cols = new HashSet[9];
Set[] boxes = new HashSet[9];
for (int i = 0; i < 9; i++) {
rows[i] = new HashSet<>();
cols[i] = new HashSet<>();
boxes[i] = new HashSet<>();
}
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
char num = board[i][j];
if (num == '.') continue;
int boxIndex = (i / 3) * 3 + (j / 3);
if (!rows[i].add(num) || !cols[j].add(num) || !boxes[boxIndex].add(num)) {
return false;
}
}
}
return true;
}
}
Metadata
Metadata
Assignees
Labels
No labels