File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -4,26 +4,26 @@ class TripleInOne {
4
4
cap = stackSize;
5
5
stk.resize (cap * 3 + 3 );
6
6
}
7
-
7
+
8
8
void push (int stackNum, int value) {
9
9
if (stk[cap * 3 + stackNum] < cap) {
10
10
stk[cap * stackNum + stk[cap * 3 + stackNum]] = value;
11
11
++stk[cap * 3 + stackNum];
12
12
}
13
13
}
14
-
14
+
15
15
int pop (int stackNum) {
16
16
if (isEmpty (stackNum)) {
17
17
return -1 ;
18
18
}
19
19
--stk[cap * 3 + stackNum];
20
20
return stk[cap * stackNum + stk[cap * 3 + stackNum]];
21
21
}
22
-
22
+
23
23
int peek (int stackNum) {
24
24
return isEmpty (stackNum) ? -1 : stk[cap * stackNum + stk[cap * 3 + stackNum] - 1 ];
25
25
}
26
-
26
+
27
27
bool isEmpty (int stackNum) {
28
28
return stk[cap * 3 + stackNum] == 0 ;
29
29
}
Original file line number Diff line number Diff line change @@ -6,26 +6,26 @@ public TripleInOne(int stackSize) {
6
6
cap = stackSize ;
7
7
stk = new int [cap * 3 + 3 ];
8
8
}
9
-
9
+
10
10
public void push (int stackNum , int value ) {
11
11
if (stk [cap * 3 + stackNum ] < cap ) {
12
12
stk [cap * stackNum + stk [cap * 3 + stackNum ]] = value ;
13
13
++stk [cap * 3 + stackNum ];
14
14
}
15
15
}
16
-
16
+
17
17
public int pop (int stackNum ) {
18
18
if (isEmpty (stackNum )) {
19
19
return -1 ;
20
20
}
21
21
--stk [cap * 3 + stackNum ];
22
22
return stk [cap * stackNum + stk [cap * 3 + stackNum ]];
23
23
}
24
-
24
+
25
25
public int peek (int stackNum ) {
26
26
return isEmpty (stackNum ) ? -1 : stk [cap * stackNum + stk [cap * 3 + stackNum ] - 1 ];
27
27
}
28
-
28
+
29
29
public boolean isEmpty (int stackNum ) {
30
30
return stk [cap * 3 + stackNum ] == 0 ;
31
31
}
You can’t perform that action at this time.
0 commit comments