package leetcode;

/**
 * https://leetcode.com/problems/remove-outermost-parentheses/
 */
public class Problem1021 {
    public String removeOuterParentheses(String S) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1021 prob = new Problem1021();
    }
}

@@ -12,16 +12,41 @@
 tcode;%0A%0A
+import java.util.Stack;%0A%0A
 /**%0A * h
@@ -200,133 +200,580 @@
     
-// TODO%0A        return null
+String answer = %22%22;%0A        Stack%3CCharacter%3E stack = new Stack%3C%3E()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1021 prob = new Problem1021()
+boolean start = true;%0A        int idx = 0;%0A        for (int i = 0; i %3C S.length(); i++) %7B%0A            if (S.charAt(i) == '(') %7B%0A                stack.add('(');%0A                if (start) %7B%0A                    idx = i;%0A                    start = false;%0A                %7D%0A            %7D else %7B%0A                stack.pop();%0A            %7D%0A            if (stack.isEmpty()) %7B%0A                start = true;%0A                answer += S.substring(idx + 1, i);%0A            %7D%0A        %7D%0A        return answer
 ;%0A  

Solve problem 1021