leetcode 22 Generat Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is:
1 | [ |
1 | class Solution { |
- Using backtrace method.
leftmeans the number of(,rightmeans the number of). Each step, if left < n , this means that we should add(to current string s , ifright<left, this means that we should add)to current string s.