diff --git a/codes/go/chapter_backtracking/n_queens.go b/codes/go/chapter_backtracking/n_queens.go index f2a74021a..5d7e7fb23 100644 --- a/codes/go/chapter_backtracking/n_queens.go +++ b/codes/go/chapter_backtracking/n_queens.go @@ -15,6 +15,7 @@ func backtrack(row, n int, state *[][]string, res *[][][]string, cols, diags1, d } *res = append(*res, newState) + return } // 遍历所有列 for col := 0; col < n; col++ {