原题
https://leetcode.com/problems/generate-parentheses/
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
思路
使用动态规划,分析子问题:每次加括号要么加在外面,要么加在旁边。
代码
1 | class Solution: |
https://leetcode.com/problems/generate-parentheses/
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
使用动态规划,分析子问题:每次加括号要么加在外面,要么加在旁边。
1 | class Solution: |
Update your browser to view this website correctly. Update my browser now