:type n: int :rtype: List[str]
(self, n)
| 24 | """ |
| 25 | class Solution(object): |
| 26 | def generateParenthesis(self, n): |
| 27 | """ |
| 28 | :type n: int |
| 29 | :rtype: List[str] |
| 30 | """ |
| 31 | result = [] |
| 32 | |
| 33 | def _generateParenthesis(x, y, parenthesis): |
| 34 | if not x and not y: |
| 35 | result.append(parenthesis) |
| 36 | return |
| 37 | |
| 38 | if y > x: |
| 39 | _generateParenthesis(x, y-1, parenthesis=parenthesis+')') |
| 40 | |
| 41 | if x: |
| 42 | _generateParenthesis(x-1, y, parenthesis=parenthesis+'(') |
| 43 | |
| 44 | _generateParenthesis(n-1, n, '(') |
| 45 | |
| 46 | return result |
| 47 |
nothing calls this directly
no outgoing calls
no test coverage detected