package
Version:
v0.0.0-...-b071cee
Opens a new window with list of versions in this module.
Published: Aug 9, 2023
License: GPL-3.0
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
22.括号生成
1. 题目描述
数字 n
代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。
示例 1:
输入:n = 3
输出:["((()))","(()())","(())()","()(())","()()()"]
示例 2:
输入:n = 1
输出:["()"]
提示:
标签
字符串
动态规划
回溯
2. 解题
采用回溯的方法,先逐个加上左括号,若数量超出n,则回溯,再加上右括号,知道左括号数等于右括号数,且等于n时将结果存到结果数组中。
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.