Two people type into empty text boxes. Their keystrokes are recorded as strings a and b, where a lowercase letter means that letter was typed and # means the backspace key was pressed. Pressing backspace on an empty box does nothing.
Return True if both boxes end up with the same text, otherwise False.
Examples
Input: a = "ab#c", b = "ad#c"
Output: True
Explanation: both boxes end with "ac".
Input: a = "a##c", b = "#a#c"
Output: True
Explanation: both boxes end with "c".
Input: a = "a#c", b = "b"
Output: False
Constraints
0 <= len(a), len(b) <= 10**4- Characters are lowercase letters or
# - Target:
O(len(a) + len(b))time
Goals
- Simulate a backspace key with a stack of characters
- Reduce both inputs to their final form before comparing
- Handle a backspace pressed on an empty buffer