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 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合. 例如,给出 n =3,生成结果为: [ "((()))", "(()())", "(())()", "()(())", "()()()" ]看到这个题,是合格的括号,有n个左括号就有n个右括号,那通过回溯法可以解决.代码如下: class Solution { public List<String>…