Stack Implementation Basics


Submit solution

Points: 10
Time limit: 2000.0s
Memory limit: 100K

Author:
Problem type

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

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

5

10

I

S

P 6

P 5

P 4

P 3

P 2

P 1

T

S

Sample Output

True

0

6

6 5

6 5 4

6 5 4 3

6 5 4 3 2

Stack Full Exception

6 5 4 3 2

2

5


Comments

There are no comments at the moment.