mycode 没有思路,大早上就有些萎靡,其实和上一个电话号码的题如出一辙啦
参考:
class Solution(object): def generateParenthesis(self, n): """ :type n: int :rtype: List[str] """ def dfs(temp,l,r): if l == 0 and r == 0: res.append(temp) #return if l>0: dfs(temp+'(',l-1,r) if r>l and r>0: dfs(temp+')',l,r-1) res = [] dfs('',n,n) return res