Python O(1) Space
\nclass Solution:\n    def backspaceCompare(self, S, T):\n        """\n        :type S: str\n        :type T: str\n        :rtype: bool\n        """\n        si
```\nclass Solution:\n    def backspaceCompare(self, S, T):\n        """\n        :type S: str\n        :type T: str\n        :rtype: bool\n        """\n        si, ti = len(S) - 1, len(T) - 1\n        count_s = count_t = 0\n        \n        while si >= 0 or ti >= 0:\n            # si stops at non-deleted character in S or -1\n            while si >= 0:\n                if S[si] == \'#\':\n                    count_s += 1\n                    si -= 1\n                elif S[si] != \'#\' and count_s > 0:\n                    count_s -= 1\n                    si -= 1\n                else:\n                    break\n            \n            # ti stops at non-deleted character in T or -1\n            while ti >= 0:\n                if T[ti] == \'#\':\n                    count_t += 1\n                    ti -= 1\n                elif T[ti] != \'#\' and count_t > 0:\n                    count_t -= 1\n                    ti -= 1\n                else:\n                    break\n            \n            \n            if (ti < 0 and si >= 0) or (si < 0 and ti >= 0):\n                # eg. S = "a#", T = "a" \n                return False\n            if (ti >= 0 and si >= 0) and S[si] != T[ti]:\n                return False\n            \n            si -= 1\n            ti -= 1\n        return True\n```
[]