数字n代表生成括号的对数请你设计一个函数用于能够生成所有可能的并且有效的括号组合。示例 1输入n 3输出[((())),(()()),(())(),()(()),()()()]核心规则左括号数量 ≤ n右括号数量不能超过左括号避免)(非法左右都用完就收集答案class Solution: def generateParenthesis(self, n: int) - List[str]: res [] def dfs(path, left, right): if left n and right n: res.append(path) return if left n: dfs(path (, left 1, right) if right left: dfs(path ), left, right 1) dfs(, 0, 0) return res