Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2032707

Browse files
authored
Unnecessary multiplication by 3 creates confusion
Dividing i and j by 3 respectively is enough for creating a unique key for the box. The extra multiplication by 3 creates confusion as it is first of all not explained in the video explanation. And also unecessary.
1 parent83fc2ee commit2032707

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎java/36-valid-sudoku.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public boolean isValidSudoku(char[][] board) {
1515

1616

1717
//Check whether Box contains duplicate elements in it
18-
if(h1.contains("box"+ (i/3)*3 +j/3 +board[i][j])){
18+
if(h1.contains("box"+ (i/3) +(j/3) +board[i][j])){
1919
returnfalse;
2020
}
21-
h1.add("box"+ (i/3)*3 +j/3 +board[i][j]);
21+
h1.add("box"+ (i/3) +(j/3) +board[i][j]);
2222
}
2323
}
2424
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp