class Solution:
    def backspaceCompare(self, s: str, t: str) -> bool:
        def check(string):
            lst = []

            for s in string:
                if s != "#":
                    lst.append(s)
                else:
                    if lst:
                        lst.pop()
                
            return lst
        
        return check(s) == check(t)