Skip to content

Commit 148e258

Browse files
Add files via upload
1 parent 2399979 commit 148e258

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
void twoStacks :: push1(int x)
2+
{
3+
arr[++top1]=x;
4+
}
5+
6+
//Function to push an integer into the stack2.
7+
void twoStacks ::push2(int x)
8+
{
9+
arr[--top2]=x;
10+
}
11+
12+
//Function to remove an element from top of the stack1.
13+
int twoStacks ::pop1()
14+
{
15+
if(top1==-1) return -1;
16+
return arr[top1--];
17+
}
18+
19+
//Function to remove an element from top of the stack2.
20+
int twoStacks :: pop2()
21+
{
22+
if(top2==size) return -1;
23+
return arr[top2++];
24+
}

0 commit comments

Comments
 (0)