← Back to problems
UNSW COMP2521 · easy

Stack ADT: PUSH / POP

Stack ADT: PUSH / POP

Implement an integer stack and process commands to feel LIFO.

Commands: PUSH x (push, no output); POP (pop and print the top, or EMPTY if empty).

Input: line 1 command count n; then n command lines. Output: one line per POP.

Example: PUSH 3 / PUSH 7 / POP / PUSH 1 / POP → 7 then 1.