We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c612b38 commit da3f422Copy full SHA for da3f422
src/main/java/com/fishercoder/solutions/_155.java
@@ -48,14 +48,10 @@ public void push(int x) {
48
}
49
50
public void pop() {
51
- if (min == stack.peek()) {
52
- stack.pop();
+ /**if the value on the top of the stack happens to be the current minimum, we'll pop twice and change
+ * the current min value to be the last min value */
53
+ if (min == stack.pop()) {
54
min = stack.pop();
- } else {
55
56
- }
57
- if (stack.isEmpty()) {
58
- min = Integer.MAX_VALUE;
59
60
61
0 commit comments