当前位置:网站首页>Recursive search sequence set
Recursive search sequence set
2022-04-22 07:28:00 【yinhua405】
Give a positive integer n , Return all the data containing n The legal sequence of parentheses .
Such as to 3 , We have to return a sequence like this ( aggregate ): ["((()))","(()())","(())()","()(())","()()()"] , And so on
set<string> generateParenthesis(int n)
{
if (n == 0)
return{ "" }; // Basic information
set<string> ans;
for (int i = 0; i < n; i++)
{
for (string left : generateParenthesis(i)) // choose s
{
for (string right : generateParenthesis(n - i - 1)) // choose t
{
ans.insert("(" + left + ")" + right); // structure
}
}
}
return ans;
}
版权声明
本文为[yinhua405]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220613324938.html
边栏推荐
- C language | quick sorting
- I.Jam-packed (均分/最大最小值) (2021年度训练联盟热身训练赛第五场)
- Why is the data stored in the leaf node of the non primary key index the primary key value
- Detailed tree array template -- Theory and code implementation
- 我们常说的栈帧的内部结构是什么样的呢?
- [number theory] congruence (4): univariate linear congruence equations (elimination of two, Chinese remainder theorem)
- In the process of class loading, the allocation area of class variables is different from that of instance variables
- Anaconda installation and use
- 下面这段SQL能否用索引优化查询性能
- LeetCode - 5 - (重复的子字符串<kmp>、最长回文子串、转置矩阵、二叉树的(左右)视图)
猜你喜欢

队列(详解)——手撕队列习题

The only storage area in the JVM where GC and oom will not occur

重写与重载的定义与区别

In the process of class loading, the allocation area of class variables is different from that of instance variables

363 · 接雨水

Leetcode - 8 - (sum of three numbers, zigzag transformation, sum of two numbers < linked list >, container with the most water, letter combination of telephone number)

Vscode, this is enough

Two algorithm questions for Microsoft intern interview -- 20220119

Leetcode - 7 - (nearest common ancestor of binary tree, rotation array, direct of binary tree, next permutation, combined sum)

C language | pointer
随机推荐
顺序表之高速缓存命中率
C language | array
[number theory] [indefinite equation] n-ary primary indefinite equation, Pell equation, Pythagoras theorem, Fermat theorem
Unknown graphics extension:. 1 jpg. }
链表习题详解
单例池、单例Bean、单例模式
[solution] Luogu p6186 [noi online 1 improvement group] bubble sorting: [bubble sorting] and [reverse order pair] problems
Idea does not display the run dashboard view window
Redis Advanced
[number theory] congruence (7): fast power, fast power of matrix
SQL Server quick start
Yapi的安装与配置(转载)
手撕算法---LRU缓存淘汰策略,问的这么频繁
L2-004 这是二叉搜索树吗?(先序输入&判断搜索二叉树&后序输出)
867 · 四键键盘
Redis進階
14 lines of code to complete arbitrary selection of image crawling
2021学习计划
SQL复习语法笔记整理,新鲜出炉
快排与归并排序