# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @return string字符串一维数组 # class Solution: def generateParenthesis(self , n: int) -> List[str]: # write code here import functools @functools.cache def dfs(n): if n<=0: return [""] res = [] for i in range(n): for i0 in dfs(i): for i1 in dfs(n-(i+1)): res.append("("+i0+")"+i1) return res return dfs(n)