#844
Backspace String Compare
pupil · 440 · lc easy +26 · verified · 49.8% accepted · 7,912 likes · top 37%
Description
Given two strings s and t, return true if they produce the same text when typed into an empty editor, treating '#' as a backspace key.
Backspacing on an empty editor has no effect.
Example 1:
Input: s = "ab#c", t = "ad#c"
Output: true
Explanation: Both s and t become "ac".
Example 2:
Input: s = "ab##", t = "c#d#"
Output: true
Explanation: Both s and t become "".
Example 3:
Input: s = "a#c", t = "b"
Output: false
Explanation: s becomes "c" while t becomes "b".
Code
1
2
3