Skip to content

Commit a9cf145

Browse files
refactor 856
1 parent 284ad4f commit a9cf145

File tree

1 file changed

+2
-2
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+2
-2
lines changed

src/main/java/com/fishercoder/solutions/_856.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public int scoreOfParentheses(String S) {
1111
Stack<Integer> stack = new Stack<>();
1212
for (int i = 0; i < S.length(); i++) {
1313
if (S.charAt(i) == '(') {
14-
stack.push(-1);
14+
stack.push(-1);//we use -1 to indicate this is a left paren '('
1515
} else {
1616
int curr = 0;
1717
while (stack.peek() != -1) {
1818
curr += stack.pop();
1919
}
20-
stack.pop();
20+
stack.pop();//this is to push the '(' off of the stack
2121
stack.push(curr == 0 ? 1 : curr * 2);
2222
}
2323
}

0 commit comments

Comments
 (0)