File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ public class ReadMe {
11
11
// backtrack: 1307[!] 1239[v] 1219[v] 1291[~] 1286[v]
12
12
// dp: 1349[!] 1340[v] 1367[v] 1388[!] 1406[!]
13
13
// divide & conquer: 932[!] 514 903[v] 327[x] 315[!]
14
- // greedy: 1354[!] 1353[x] 1338[v] 1383[!] 1403
15
- // stack: 1190[!] 975[x] 1381[v] 901[v] 946
14
+ // greedy: 1354[!] 1353[x] 1338[v] 1383[!] 1403[v]
15
+ // stack: 1190[!] 975[x] 1381[v] 901[v] 946[v]
16
16
// binary search: 1351[v] 1337[v] 1292[!] 1235[!] 1237
17
17
// 2 pointers: 1248[*] 1234[v] 986[v] 826[x] 977
18
18
// sliding window: 1208[v] 1040[!] 995[!] 567[v] 978[v]
Original file line number Diff line number Diff line change
1
+ package stack ;
2
+
3
+ public class Problem946_ValidateStackSequences {
4
+
5
+ public boolean validateStackSequences (int [] pushed , int [] popped ) {
6
+ int i = -1 , j = 0 ;
7
+ for (int x : pushed ) {
8
+ pushed [++i ] = x ;
9
+ while (i >= 0 && pushed [i ] == popped [j ]) {
10
+ j ++;
11
+ i --;
12
+ }
13
+ }
14
+ return j == popped .length ;
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments