Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SudokuSolver is not checking isSafe for rows correctly. #1388

Open
Akhil-Selukar opened this issue Oct 2, 2024 · 1 comment
Open

SudokuSolver is not checking isSafe for rows correctly. #1388

Akhil-Selukar opened this issue Oct 2, 2024 · 1 comment

Comments

@Akhil-Selukar
Copy link

description : In isSafe method below loop is intended to check if the number we are trying to insert is already available in the row or not. But below loop is iterating over columns and not on rows so it is checking if the number already exists in column or not instead of row.

// check the row
for (int i = 0; i < board.length; i++) {
    // check if the number is in the row
    if (board[row][i] == num) {
        return false;
    }
}

Link for code snippet : https://github.com/kunal-kushwaha/DSA-Bootcamp-Java/blob/6bc4d8bf8ac5e434ac9083e1c01210e42f2a762c/lectures/14-recursion/code/src/com/kunal/backtracking/SudokuSolver.java#L81C9-L86C10

@Akhil-Selukar
Copy link
Author

Akhil-Selukar commented Oct 2, 2024

Hi @kunal-kushwaha I have raised below PR for the issue mentioned above.
Can you please have a look once?

PR link : #1389

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant