题解 | #括号生成#
括号生成
http://www.nowcoder.com/practice/c9addb265cdf4cdd92c092c655d164ca
# # # @param n int整型 # @return string字符串一维数组 # class Solution: def generateParenthesis(self , n ): # write code here if n==0: return [] result = [] self.helpler(n, n, '', result) return result def helpler(self, l, r, item, result): if r<l: return if l==0 and r == 0: result.append(item) if l>0: self.helpler(l-1, r, item +'(', result) if r>0: self.helpler(l, r-1, item +')', result)