# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param n int整型 # @return string字符串一维数组 # class Solution: def ser(self, used, ava, st): l,r = used le,re = ava if le==0 and re==0: self.all.append(st) print(used,ava) if le>0: self.ser([l+1,r],[le-1,re],st+'(') if re>0 and l-r>0: self.ser([l,r+1],[le,re-1],st+')') def generateParenthesis(self , n: int) -> List[str]: # write code here self.all = [] self.ser([0,0],[n,n],'') return self.all