public ArrayList<String> generateParenthesis(int n) {
        if(n == 0){
            return new ArrayList<String>();
        }
        if(n == 1){
            ArrayList<String> list = new ArrayList<String>();
            list.add("()");
            return list;
        }
        ArrayList<String> lastList = generateParenthesis(n - 1);
        ArrayList<String> resultList = new ArrayList<String>();

        for(String item : lastList){
            char [] charArr = item.toCharArray();
            for(int i = 0; i < charArr.length; i++){
                char [] newCharArr = new char[charArr.length + 2];
//                System.out.println("new Len:" + newCharArr.length);
                for(int j = 0; j < newCharArr.length; j++){
                    if(j <= i){
                        newCharArr[j] = charArr[j];
                    } else if( j == i+1){
                        newCharArr[j] = '(';
                    } else if( j == i+2){
                        newCharArr[j] = ')';
                    } else {
                        newCharArr[j] = charArr[j-2];
                    }
                }
                String newStr = String.valueOf(newCharArr);
                if(!resultList.contains(newStr)){
                    resultList.add(newStr);
                }
            }
            
        }

        return resultList;
    }