← back to unit
Medium
# stacks medium
The Typing Time Machine
You type word by word; undo unwrites the LAST word. Time travel for sentences! ⏪
You get tokens — words, or undo (never more undos than words). Print the surviving sentence with single spaces, or blank page.
Example:
Input: tokens = ["i", "love", "cats", "undo", "dogs"]
Output: i love dogs
i, love, cats get pushed. undo pops cats off. Then dogs gets pushed — leaving i, love, dogs.
💡 need a hint?
stk-typing-time-machine.py🔒 given lines are locked — write your code in between
loading...