Given two strings
true if they are equal when both are typed into empty text editors.
'#' means a backspace character.
Note that after backspacing an empty text, the text will continue empty.
Input: s = "ab#c", t = "ad#c" Output: true Explanation: Both s and t become "ac".
Input: s = "ab##", t = "c#d#" Output: true Explanation: Both s and t become "".
Input: s = "a#c", t = "b" Output: false Explanation: s becomes "c" while t becomes "b".
1 <= s.length, t.length <= 200
tonly contain lowercase letters and
Follow up: Can you solve it in
O(n) time and
class Solution: def backspaceCompare(self, S: str, T: str) -> bool: def bckspc(string): stack= for i in string: if i =='#': try: stack.pop() except: pass else: stack.append(i) return ''.join(stack) return (bckspc(S)==bckspc(T))