603. Comparing With Backspaces
Two strings contain lowercase letters and the character #, which means a
backspace and deletes the character before it. A backspace on an empty string
does nothing.
Print YES if the two strings are equal once every backspace is applied, and
NO otherwise.
Building both results with a stack is correct and uses extra memory. Walking
BACKWARDS from the end of each string needs none: a # means skip the next real
character, so a counter of pending skips is enough to find the next surviving
character on each side.
Reading forwards cannot work, because whether a character survives depends on what comes after it.
Constraints - `1 ≤ length of each string ≤ 200000` - Each string contains only lowercase letters and `#`.
Input
The first line contains the first string. The second line contains the second string.
Output
Print YES if the two strings are equal after applying the backspaces, otherwise NO.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.