File tree 3 files changed +21
-21
lines changed
3 files changed +21
-21
lines changed Original file line number Diff line number Diff line change @@ -72,21 +72,21 @@ class MinStack {
72
72
s1 = new ArrayDeque<> ();
73
73
s2 = new ArrayDeque<> ();
74
74
}
75
-
75
+
76
76
public void push (int x ) {
77
77
s1. push(x);
78
78
s2. push(s2. isEmpty() || s2. peek() >= x ? x : s2. peek());
79
79
}
80
-
80
+
81
81
public void pop () {
82
82
s1. pop();
83
83
s2. pop();
84
84
}
85
-
85
+
86
86
public int top () {
87
87
return s1. peek();
88
88
}
89
-
89
+
90
90
public int min () {
91
91
return s2. peek();
92
92
}
Original file line number Diff line number Diff line change @@ -84,17 +84,17 @@ class Solution {
84
84
* @param {number[]} popped
85
85
* @return {boolean}
86
86
*/
87
- var validateStackSequences = function (pushed , popped ) {
88
- let s = [];
89
- let q = 0 ;
90
- for (let num of pushed) {
91
- s .push (num);
92
- while (s .length > 0 && s[s .length - 1 ] == popped[q]) {
93
- ++ q;
94
- s .pop ();
95
- }
87
+ var validateStackSequences = function (pushed , popped ) {
88
+ let s = [];
89
+ let q = 0 ;
90
+ for (let num of pushed) {
91
+ s .push (num);
92
+ while (s .length > 0 && s[s .length - 1 ] == popped[q]) {
93
+ ++ q;
94
+ s .pop ();
96
95
}
97
- return s .length == 0 ;
96
+ }
97
+ return s .length == 0 ;
98
98
};
99
99
```
100
100
Original file line number Diff line number Diff line change 3
3
* @param {number[] } popped
4
4
* @return {boolean }
5
5
*/
6
- var validateStackSequences = function ( pushed , popped ) {
6
+ var validateStackSequences = function ( pushed , popped ) {
7
7
let s = [ ] ;
8
8
let q = 0 ;
9
9
for ( let num of pushed ) {
10
- s . push ( num ) ;
11
- while ( s . length > 0 && s [ s . length - 1 ] == popped [ q ] ) {
12
- ++ q ;
13
- s . pop ( ) ;
14
- }
10
+ s . push ( num ) ;
11
+ while ( s . length > 0 && s [ s . length - 1 ] == popped [ q ] ) {
12
+ ++ q ;
13
+ s . pop ( ) ;
14
+ }
15
15
}
16
16
return s . length == 0 ;
17
- } ;
17
+ } ;
You can’t perform that action at this time.
0 commit comments