Problem Statement
Design a data-structure SpecialStack that supports all the stack operations like push(),
pop(), isEmpty(), isFull() and an additional operation getMin() which should return minimum
element from the SpecialStack.
Example 1:
Enter the size of stack - 5
23 67 657 80 70
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
1
>> Stack Full
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
3
>> True
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
2
>> Popped element is 70
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
5
>> 23
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
6
Example 2:
Enter the size of stack - 2
43 98
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
2
>>> Popped Element is 98
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
2
>>> Popped Element is 43
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
24
>>> True
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
5
>>> 2
Stack empty
Enter your choice:
1.push 2.pop 3.isFull 4.isEmpty 5.minElem 6.exit
6