LeetCode OJ-22.Generate Parentheses(回溯法)
题目描述
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:
[ "((()))", "(()())", "(())()", "()(())", "()()()" ]
Subscribe to see which companies asked this question
题目理解
给定一个整数n,代表n对括号,”()”算一对,以n对括号,求解所有合法的括号组合组合,举个例子:”()”就是合法的,然而”)()”就是不合法的。这题可以使用回溯法解决,并不会超时。这里有一个恒成立的条件,在任意位置