FunctionRacerProblemsRace

Typing With Home and End

EasyStacks and queuesPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Stacks and queues problems