Refactor
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// 深度优先遍历:
|
||||
// 接收参数为每个节点的状态
|
||||
// 遍历结果可以用指针放在接收参数保存,也可以通过声明一个 class 的成员来保存
|
||||
void dfs(string current, int left, int right, vector<string> &result) {
|
||||
void S0022::dfs(string current, int left, int right, vector<string> &result) {
|
||||
// 讨论边界条件(结束条件)
|
||||
// 不必讨论起始条件,因为初始化的工作会在 dfs 函数外完成。
|
||||
if (left == 0 && right == 0) {
|
||||
@@ -22,7 +22,7 @@ void dfs(string current, int left, int right, vector<string> &result) {
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> Solution::generateParenthesis(int n) {
|
||||
vector<string> S0022::generateParenthesis(int n) {
|
||||
// 初始化
|
||||
vector<string> result = {};
|
||||
dfs("", n, n, result);
|
||||
|
||||
Reference in New Issue
Block a user