coderwhy大神前端系统直播课
2022-11-17 23:12 作者:邱邱邱2585093180 | 我要投稿
在解决第x层之前,假设第x-1层已经得到的解决 public List> solveNQueens(int n, int x) { if (x == 1) { // 正在棋盘的第1行摆放皇后 List
> solutionOfFirstRow = new ArrayList<>(); for (int i = 1; i <= n; i++) { solutionOfFirstRow.add(Collections.singletonList(queenAt(i, n))); } return solutionOfFirstRow; } // 每个元素代表一个解 // 其中的每个String都是N长度的 // 例如:现在正在解决4皇后问题的第3层,那么假设第2层已经得到了解决 // [ // [".Q.."] // ["...Q"] // ] List
>