Simulate a stack using an array. Process a sequence of PUSH x and POP operations, then print the final stack contents from bottom to top.
Input / Output
Input: first line N (number of operations), then N lines each "PUSH x" or "POP". Output: the final stack contents, bottom to top, space-separated — or "empty" if nothing remains.
Examples
Input
3 PUSH 1 PUSH 2 POP
Expected Output
1
Input
4 PUSH 5 PUSH 10 PUSH 15 POP
Expected Output
5 10
+ 2 hidden tests checked on Submit.
Main.java is the entry point. Add extra classes for OOP exercises — they compile together.
Run your code to see test results here.