Typing session replay
EasyOnline Assessment
Replay a recorded typing session and report the text that ended up on the screen.
keys lists the keys pressed, one character per key press, starting with an empty text and Caps Lock off:
^toggles Caps Lock. It types nothing, and it never changes characters that were already typed.<is Backspace: it deletes the last character on the screen (whatever it is, including a space). On an empty text it does nothing. It never changes the Caps Lock state.- A letter is typed as the key shows it: a lowercase letter means Shift was not held, an uppercase letter means Shift was held. With Caps Lock on, the case is inverted: an unshifted letter appears in uppercase and a shifted letter appears in lowercase. With Caps Lock off, the letter appears as given.
- Any other character (digits, spaces,
!) is typed unchanged. Caps Lock does not affect it.
Input: keys, a string.
Output: a string, the final text. It may be empty.
Example 1
- Input:
- ["helLo^ wor<ld^!"]
- Output:
- "helLo WOLD!"
- Explanation
helLois typed as is (the capital L means Shift was held).^switches Caps Lock on, soWORis typed,<deletes theR, thenLDfollows.^switches Caps Lock off and!is typed.
Example 2
- Input:
- ["^aBc^<d"]
- Output:
- "Abd"
- Explanation
- With Caps Lock on,
abecomesA, but the shiftedBbecomesbandcbecomesC. Caps Lock goes off,<deletes the last typed character (C), anddis typed:Abd.
Example 3
- Input:
- ["<<a<"]
- Output:
- ""
- Explanation
- A backspace with nothing typed does nothing, twice. Then
ais typed and the last<deletes it, leaving an empty text.
Constraints
0 <= keys.length <= 10,000keyscontains letters, digits, spaces and the symbols^,<and!