```
class Solution:
# @param an integer
# @return a list of string
def generateParenthesis(self, n):
res = {'()'}
for i in range(n-1):
res = {r[:m+1]+'()'+r[m+1:] for r in res for m in range(i, 2*i+2)}
return list(res)
```

It seems set is enough