Dsa
Stack
Medium
Undo Log
You are building a text editor that supports 'undo' functionality. The editor receives commands as input, where each command is either 'ADD <text>' to add text, or 'UNDO' to remove the last added text. Your task is to process a series of commands and output the final text after executing all commands.
Example input:
ADD hello
ADD world
UNDO
ADD editor
Output:
hello editor
Key concepts
stacksimulationcommands
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now