β back to unit
Medium
# stacks medium
Undo!
Every artist's favorite button. Each action lands on the history pile; undo erases the most recent one. π¨
You get actions β either a real action word or undo (never more undos than actions available). Print the surviving actions in order, comma-separated, or nothing.
Example:
Input: actions = ["draw", "erase", "undo", "paint"]
Output: draw,paint
draw and erase get pushed, undo pops erase back off, then paint gets pushed β leaving draw,paint.
π‘ need a hint?
stk-undo.pyπ given lines are locked β write your code in between
loading...