class Solution:
# @param an integer
# @return a list of string
def recurGen(self,l,r,rst,crt):
if l==r==0:
rst.append(crt)
return
if l>0:
self.recurGen(l-1,r,rst,crt+'(')
if r>l:
self.recurGen(l,r-1,rst,crt+')')
def generateParenthesis(self, n):
rst=[]
self.recurGen(n,n,rst,'')
return rst
Sunday, September 7, 2014
Leetcode: Generate Parentheses @Python
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment