Final String After Backspaces
EasyP2Coding
You type the characters of s one by one. A letter or digit is appended to the text. The character # acts as a backspace: it deletes the most recently typed character that is still in the text, and does nothing if the text is empty.
Return the final text. It may be empty.
Example 1
- Input
- s = "ab#c"
- Output
- "ac"
Example 2
- Input
- s = "a##b"
- Output
- "b"
Example 3
- Input
- s = "###"
- Output
- ""
Constraints
- 0 <= s.length <= 10^5
- s consists of lowercase letters, digits and '#'
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 11. ⌘Enter runs, ⌘⇧Enter submits.