String:Generate 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:
[
"((()))",
"(()())",
"(())()",
"()(())",
"()()()"
]

public List generateParenthesis(int n) {
        List aryList = new ArrayList();
        getString(aryList, "", 0, 0, n);
        return aryList;
    }
    
    private void getString(List list,String str,int open,int close,int max) {
        if (str.length()==2*max) {
            list.add(str);
            return;
        }
        if (open

你可能感兴趣的:(String:Generate Parentheses)