Typing With Home and End
keys lists key presses in order. A lowercase letter is typed at the cursor, and the cursor moves past it. < is the Home key: it moves the cursor to the start of the text. > is the End key: it moves the cursor to the end of the text. The text starts empty.
Return the final text.
Example 1
keys "ab<cd>ef"
returns "cdabef"
After ab, Home puts cd in front of it, then End adds ef at the end.
Example 2
keys "<<x<y>z"
returns "yxz"
x is typed, Home puts y before it, and End adds z at the end.
Constraints
0 <= len(keys) <= 60keysholds lowercase letters,<and>only
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Stacks and queues problems
- Where cd LandsEasy
- Balanced Outside QuotesMedium
- Browser Back and ForwardMedium
- Convoys at the GateMedium
- Daily TemperaturesMedium
- Decode StringMedium
- Flip and Double BracketsMedium
- Keep the Digits, One of Each LetterMedium