Point mistake out?


  • 0
    S
    class Solution(object):
        def generateParenthesis(self, n):
            """
            :type n: int
            :rtype: List[str]
            """
            if n == 0:
                return []
            
            if n == 1:
                return ['()']
            
            return self.findAll(n)
            
        def findAll(self, n):
            
            if n == 1:
                return ['()']
            
            recur_list = self.findAll(n-1)
            
            paran = []
            for r in recur_list:
                center = '(' + r + ')'
                paran.append(center)
                left = '()' + r
                right = r + '()'
                paran.append(left)
                if left != right:
                    paran.append(right)
            return paran

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.