File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
src/main/java/g0001_0100/s0051_n_queens Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 10
10
public class Solution {
11
11
public List <List <String >> solveNQueens (int n ) {
12
12
char [][] board = new char [n ][n ];
13
- for (int i = 0 ; i < n ; i ++) for (int j = 0 ; j < n ; j ++) board [i ][j ] = '.' ;
14
- List <List <String >> res = new ArrayList <List <String >>();
13
+ for (int i = 0 ; i < n ; i ++) {
14
+ for (int j = 0 ; j < n ; j ++) {
15
+ board [i ][j ] = '.' ;
16
+ }
17
+ }
18
+ List <List <String >> res = new ArrayList <>();
15
19
int [] leftRow = new int [n ];
16
20
int [] upperDiagonal = new int [2 * n - 1 ];
17
21
int [] lowerDiagonal = new int [2 * n - 1 ];
@@ -30,7 +34,6 @@ void solve(
30
34
res .add (construct (board ));
31
35
return ;
32
36
}
33
-
34
37
for (int row = 0 ; row < board .length ; row ++) {
35
38
if (leftRow [row ] == 0
36
39
&& lowerDiagonal [row + col ] == 0
You can’t perform that action at this time.
0 commit comments