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

 

相关文章:

  • 2021-12-11
  • 2022-03-04
  • 2021-10-09
  • 2022-01-21
  • 2021-11-26
  • 2022-02-21
  • 2021-12-25
  • 2021-09-02
猜你喜欢
  • 2022-02-05
  • 2021-11-26
  • 2021-07-08
  • 2021-12-29
  • 2021-11-26
相关资源
相似解决方案