Stacks and undo
Read the top value after performing the listed operations, or return "Empty".
Examples
Example 1
Input
push A, push B, pop
Expected output
A
Example 2
Input
push A, pop
Expected output
Empty
Hints and solution
Hint 1
Write the stack as a list and edit its right end in each step.
Reveal worked answer
Push opens A then B. A pop removes B so A is next. A pop on the only entry leaves the stack empty.