Skip to content

Bug Report for valid-sudoku #4397

@pavan1603

Description

@pavan1603

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions