标签:parent pen list rate targe title new des public
public class Solution { public IList<string> GenerateParenthesis(int n) { List<string> list = new List<string>(); backtrack(list, "", 0, 0, n); return list; } private void backtrack(List<String> list, String str, int open, int close, int max) { if (str.Length == max * 2) { list.Add(str); return; } if (open < max) { backtrack(list, str + "(", open + 1, close, max); } if (close < open) { backtrack(list, str + ")", open, close + 1, max); } } }
https://leetcode.com/problems/generate-parentheses/#/description
标签:parent pen list rate targe title new des public
原文地址:http://www.cnblogs.com/asenyang/p/6851664.html