# stacks medium

Predict the Pops

Before touching the keyboard, predict on paper what this machine spits out — THEN code it to check yourself. 🔮

You get commandspush:x or pop (pops always valid). Print everything popped, in pop order, space-separated on one line.

Example:

Input: commands = ["push:a", "push:b", "pop", "push:c", "pop", "pop"] Output: b c a

Push a, b (pile: a,b); pop removes b; push c (pile: a,c); pop removes c; pop removes a — popped in order b, c, a.

💡 need a hint?

stk-predict-pops.py🔒 given lines are locked — write your code in between
loading...