Skip to content

Commit e3c0e9e

Browse files
committed
update 1021.remove-outermost-parentheses.java
1 parent d8ab7f7 commit e3c0e9e

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

1021.remove-outermost-parentheses.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,11 @@ public String removeOuterParentheses(String S) {
9898
// stacked openings, then it pops off from the stack whenever it finds
9999
// closing.
100100
if (c == '(') {
101+
if (open != 0) sb.append(c);
101102
open++;
102-
if (open == 1)
103-
continue;
104103
} else if (c == ')') {
105104
open--;
106-
}
107-
108-
// If open > 0, Meaning theres, an open outer parenthesis:
109-
// Append into buf
110-
if (open > 0) {
111-
sb.append(c);
105+
if (open != 0) sb.append(c);
112106
}
113107
}
114108

0 commit comments

Comments
 (0)