Prepare 1.0.0 release (#1044)

* Update the book with the thrid revised edition

* Fix a typo

* Update the contributors' information

* Update the mindmap

* Update the version number
This commit is contained in:
Yudong Jin
2024-01-14 03:16:20 +08:00
committed by GitHub
parent b9ae4ffe9a
commit f6976978dd
33 changed files with 50 additions and 49 deletions

View File

@@ -8,7 +8,7 @@
#define MAX_SIZE 100
/* 回溯算法:N 皇后 */
/* 回溯算法:n 皇后 */
void backtrack(int row, int n, char state[MAX_SIZE][MAX_SIZE], char ***res, int *resSize, bool cols[MAX_SIZE],
bool diags1[2 * MAX_SIZE - 1], bool diags2[2 * MAX_SIZE - 1]) {
// 当放置完所有行时,记录解
@@ -40,7 +40,7 @@ void backtrack(int row, int n, char state[MAX_SIZE][MAX_SIZE], char ***res, int
}
}
/* 求解 N 皇后 */
/* 求解 n 皇后 */
char ***nQueens(int n, int *returnSize) {
char state[MAX_SIZE][MAX_SIZE];
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位

View File

@@ -6,7 +6,7 @@
#include "../utils/common.hpp"
/* 回溯算法:N 皇后 */
/* 回溯算法:n 皇后 */
void backtrack(int row, int n, vector<vector<string>> &state, vector<vector<vector<string>>> &res, vector<bool> &cols,
vector<bool> &diags1, vector<bool> &diags2) {
// 当放置完所有行时,记录解
@@ -33,7 +33,7 @@ void backtrack(int row, int n, vector<vector<string>> &state, vector<vector<vect
}
}
/* 求解 N 皇后 */
/* 求解 n 皇后 */
vector<vector<vector<string>>> nQueens(int n) {
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
vector<vector<string>> state(n, vector<string>(n, "#"));

View File

@@ -7,7 +7,7 @@
namespace hello_algo.chapter_backtracking;
public class n_queens {
/* 回溯算法:N 皇后 */
/* 回溯算法:n 皇后 */
void Backtrack(int row, int n, List<List<string>> state, List<List<List<string>>> res,
bool[] cols, bool[] diags1, bool[] diags2) {
// 当放置完所有行时,记录解
@@ -38,7 +38,7 @@ public class n_queens {
}
}
/* 求解 N 皇后 */
/* 求解 n 皇后 */
List<List<List<string>>> NQueens(int n) {
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
List<List<string>> state = [];

View File

@@ -4,7 +4,7 @@
* Author: liuyuxin (gvenusleo@gmail.com)
*/
/* 回溯算法:N 皇后 */
/* 回溯算法:n 皇后 */
void backtrack(
int row,
int n,
@@ -46,7 +46,7 @@ void backtrack(
}
}
/* 求解 N 皇后 */
/* 求解 n 皇后 */
List<List<List<String>>> nQueens(int n) {
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
List<List<String>> state = List.generate(n, (index) => List.filled(n, "#"));

View File

@@ -4,7 +4,7 @@
package chapter_backtracking
/* 回溯算法:N 皇后 */
/* 回溯算法:n 皇后 */
func backtrack(row, n int, state *[][]string, res *[][][]string, cols, diags1, diags2 *[]bool) {
// 当放置完所有行时,记录解
if row == n {
@@ -35,6 +35,7 @@ func backtrack(row, n int, state *[][]string, res *[][][]string, cols, diags1, d
}
}
/* 求解 n 皇后 */
func nQueens(n int) [][][]string {
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
state := make([][]string, n)

View File

@@ -9,7 +9,7 @@ package chapter_backtracking;
import java.util.*;
public class n_queens {
/* 回溯算法:N 皇后 */
/* 回溯算法:n 皇后 */
public static void backtrack(int row, int n, List<List<String>> state, List<List<List<String>>> res,
boolean[] cols, boolean[] diags1, boolean[] diags2) {
// 当放置完所有行时,记录解
@@ -40,7 +40,7 @@ public class n_queens {
}
}
/* 求解 N 皇后 */
/* 求解 n 皇后 */
public static List<List<List<String>>> nQueens(int n) {
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
List<List<String>> state = new ArrayList<>();

View File

@@ -4,7 +4,7 @@
* Author: Justin (xiefahit@gmail.com)
*/
/* 回溯算法:N 皇后 */
/* 回溯算法:n 皇后 */
function backtrack(row, n, state, res, cols, diags1, diags2) {
// 当放置完所有行时,记录解
if (row === n) {
@@ -30,7 +30,7 @@ function backtrack(row, n, state, res, cols, diags1, diags2) {
}
}
/* 求解 N 皇后 */
/* 求解 n 皇后 */
function nQueens(n) {
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
const state = Array.from({ length: n }, () => Array(n).fill('#'));

View File

@@ -14,7 +14,7 @@ def backtrack(
diags1: list[bool],
diags2: list[bool],
):
"""回溯算法:N 皇后"""
"""回溯算法:n 皇后"""
# 当放置完所有行时,记录解
if row == n:
res.append([list(row) for row in state])
@@ -37,7 +37,7 @@ def backtrack(
def n_queens(n: int) -> list[list[list[str]]]:
"""求解 N 皇后"""
"""求解 n 皇后"""
# 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
state = [["#" for _ in range(n)] for _ in range(n)]
cols = [False] * n # 记录列是否有皇后

View File

@@ -4,7 +4,7 @@
* Author: codingonion (coderonion@gmail.com)
*/
/* 回溯算法:N 皇后 */
/* 回溯算法:n 皇后 */
fn backtrack(row: usize, n: usize, state: &mut Vec<Vec<String>>, res: &mut Vec<Vec<Vec<String>>>,
cols: &mut [bool], diags1: &mut [bool], diags2: &mut [bool]) {
// 当放置完所有行时,记录解
@@ -35,7 +35,7 @@ fn backtrack(row: usize, n: usize, state: &mut Vec<Vec<String>>, res: &mut Vec<V
}
}
/* 求解 N 皇后 */
/* 求解 n 皇后 */
fn n_queens(n: usize) -> Vec<Vec<Vec<String>>> {
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
let mut state: Vec<Vec<String>> = Vec::new();

View File

@@ -4,7 +4,7 @@
* Author: nuomi1 (nuomi1@qq.com)
*/
/* N */
/* n */
func backtrack(row: Int, n: Int, state: inout [[String]], res: inout [[[String]]], cols: inout [Bool], diags1: inout [Bool], diags2: inout [Bool]) {
//
if row == n {
@@ -34,7 +34,7 @@ func backtrack(row: Int, n: Int, state: inout [[String]], res: inout [[[String]]
}
}
/* N */
/* n */
func nQueens(n: Int) -> [[[String]]] {
// n*n 'Q' '#'
var state = Array(repeating: Array(repeating: "#", count: n), count: n)

View File

@@ -4,7 +4,7 @@
* Author: Justin (xiefahit@gmail.com)
*/
/* 回溯算法:N 皇后 */
/* 回溯算法:n 皇后 */
function backtrack(
row: number,
n: number,
@@ -38,7 +38,7 @@ function backtrack(
}
}
/* 求解 N 皇后 */
/* 求解 n 皇后 */
function nQueens(n: number): string[][][] {
// 初始化 n*n 大小的棋盘,其中 'Q' 代表皇后,'#' 代表空位
const state = Array.from({ length: n }, () => Array(n).fill('#'));