Multipop on Stack
Submit solution
C++, Python
Points:
20 (partial)
Time limit:
10.0s
Memory limit:
64M
Authors:
Problem type
Allowed languages
Problem Statement
You are expected to implement the basic functionality of a stack data structure. The operations involved are as follows:
I - checks for stack empty condition
S - gives the current size of the stack
P 1 - pushes 1 onto the stack
O - pops an element from the stack
T - returns the top of the stack
M 3 - Muti-pop 3 elements
and so on.
Input format:
First line contains the size of the stack and second line reads the number of operations on the stack followed by commands in each line.
Output format:
The output for each command should be displayed.
Sample Input
3
10
P 1
P 2
P 3
M 2
P 4
M 3
S
I
M 1
S
Sample Output
1
1 2
1 2 3
3
2
1 4
4
1
Stack Empty Exception
0
True
Stack Empty Exception
0
Comments