leetcode [#22] | GCidea's blog
目录1. 题目2. 解决方案3. 注意事项
题目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:
[ “((()))”, “(()())”, “(())()”, “()(())”, “()()()”]
解决方案123456789101112131415public class Solution { public List<String> generateParenthesis(int n) { List<String> res = new ArrayList<>(); recursivelyGetParenthesis(res, "", 0, 0, n); return res; } private static void recursivelyGetParenth...阅读全文
题目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:
[ “((()))”, “(()())”, “(())()”, “()(())”, “()()()”]
解决方案123456789101112131415public class Solution { public List<String> generateParenthesis(int n) { List<String> res = new ArrayList<>(); recursivelyGetParenthesis(res, "", 0, 0, n); return res; } private static void recursivelyGetParenth...阅读全文