public List<String> generateParenthesis2(int n) {
        List<String> result = new ArrayList<String>();
        if(n == 0) return result;
        if(n == 1){
            result.add("()");
            return result;
        }
        List<String> prevStrings = generateParenthesis2(n - 1);
        for(String s: prevStrings){
            if(!result.contains("(" + s + ")")) result.add("(" + s + ")");
            if(!result.contains("()" + s)) result.add("()" + s);
            if(!result.contains(s + "()")) result.add(s + "()");
        }
        return result;
    }