Skip to content

Commit 56ce522

Browse files
Update 22. 括号生成.md
1 parent 03c78c6 commit 56ce522

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Depth First Search/22. 括号生成.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func generateParenthesis(n int) []string {
4242
return
4343
}
4444
if num1 > 0 {
45-
dfs(num1 - 1, num2, s + "(")
45+
dfs(num1 - 1, num2, s + "(") // 类似于回溯,此处不对字符串 s 本身做修改,所以不需要新增字符串再删除字符串的操作
4646
}
4747
if num1 < num2 {
4848
dfs(num1, num2 - 1, s + ")")

0 commit comments

Comments
 (0)