Backend Engineer
Senior
programming
Given two strings s and t, return true if they are equal when both are typed into empty text editors. That means if a string contains '#' characters, these characters represent a backspace. They reduce the previous characters in the string by one. Note that no two characters in the string will be the same. Please implement the following function:
def backspaceCompare(s: str, t: str) -> bool:
Constraints:
- 1 <= s.length, t.length <= 200
- s and t only contain lowercase letters and '#' characters.
Example 1:
Input: s = "ab#c", t = "ad#c"
Output: true
Example 2:
Input: s = "ab##", t = "c#d#"
Output: true
Suggested Answer