public List<String> generateParenthesis2(int n) {
        List<String> result = new ArrayList<String>();
        Stack<Integer> numStack = new Stack<Integer>();
        int nowNum = n;
        boolean nowNumPoped = false;

        while (!(nowNumPoped && nowNum == n)) {
            if (!nowNumPoped) {
                if (nowNum>0) {
                    numStack.push(nowNum);
                    if (numStack.size()+nowNum == n+1)
                        nowNum--;
                } else {
                    result.add(generateString(numStack,n));
                    nowNum = numStack.pop();
                    nowNumPoped = true;
                }
            } else {
                nowNum--;
                nowNumPoped = false;
            }

        }
        return result;
    }