Skip to content

Commit 8e7a7fb

Browse files
committed
Update Solution.java
1 parent 2a664e9 commit 8e7a7fb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/g0001_0100/s0051_n_queens/Solution.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
public class Solution {
1111
public List<List<String>> solveNQueens(int n) {
1212
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<>();
1519
int[] leftRow = new int[n];
1620
int[] upperDiagonal = new int[2 * n - 1];
1721
int[] lowerDiagonal = new int[2 * n - 1];
@@ -30,7 +34,6 @@ void solve(
3034
res.add(construct(board));
3135
return;
3236
}
33-
3437
for (int row = 0; row < board.length; row++) {
3538
if (leftRow[row] == 0
3639
&& lowerDiagonal[row + col] == 0

0 commit comments

Comments
 (0)