[Python] 2 solutions - O(1) space - Clean & Concise
\u2714\uFE0F Solution 1: Using stack\npython\nclass Solution:\n    def backspaceCompare(self, s: str, t: str) -> bool:\n        def getResult(s):\n            s
**\u2714\uFE0F Solution 1: Using stack**\n```python\nclass Solution:\n    def backspaceCompare(self, s: str, t: str) -> bool:\n        def getResult(s):\n            st = []\n            for c in s:\n                if c == \'#\':\n                    if st:\n                        st.pop()\n                else:\n                    st.append(c)\n            return "".join(st)\n        \n        return getResult(s) == getResult(t)\n```\nComplexity:\n- Time: `O(M + N)`, where `M <= 200` is length of string `s`, `N <= 200` is length of string `t`.\n- Space: `O(M + N)`\n\n---\n**\u2714\uFE0F Solution 2: Reverse Iterator**\n```python\nclass Solution:\n    def backspaceCompare(self, s: str, t: str) -> bool:\n        i = len(s) - 1\n        j = len(t) - 1\n        while i >= 0 or j >= 0:\n            skipS = 0\n            skipT = 0\n            while i >= 0:\n                if s[i] == \'#\':\n                    skipS += 1\n                    i -= 1\n                elif skipS > 0:\n                    skipS -= 1\n                    i -= 1\n                else:\n                    break\n                    \n            while j >= 0:\n                if t[j] == \'#\':\n                    skipT += 1\n                    j -= 1\n                elif skipT > 0:\n                    skipT -= 1\n                    j -= 1\n                else:\n                    break\n                    \n            if (i >= 0) != (j >= 0):\n                return False\n            \n            if i >= 0 and j >= 0 and s[i] != t[j]:\n                return False\n            i -= 1\n            j -= 1\n            \n        return True\n```\nComplexity:\n- Time: `O(M + N)`, where `M <= 200` is length of string `s`, `N <= 200` is length of string `t`.\n- Space: `O(1)`
[]