22. Generate Parentheses

class Solution(object):
    def generateParenthesis(self, n):
        """
        :type n: int
        :rtype: List[str]
        """
        result=[]
        self.recursion(result,"",n,n)
        return result
    def recursion(self,result,curr,left,right):
        if left==right==0:
            result.append(curr)
        else:
            if left>0:
                self.recursion(result,curr+'(',left-1,right)
            if left

你可能感兴趣的:(22. Generate Parentheses)