LeetCode第22题:Generate Parenthese总结

题目

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

For example, given n = 3, a solution set is:

“((()))”, “(()())”, “(())()”, “()(())”, “()()()”

  • 大意:给定n对括号,写一个函数来生成所有正确的配对串。

思路

生成所有的可能,然后注意检测是不是符合要求。

##代码
(Python)

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注