classSolution:defgenerateParenthesis(self,n:int) -> List[str]:defgen(current,unused,used,result):if unused ==0and used == n: result.append(current)if unused >0:gen(current +'(', unused -1, used, result)if used + unused < n and used < n:gen(current +')', unused, used +1, result)return result res = []gen('', n, 0, res)return res