Short O(n) time O(1) space Python solution, NO iterator
Just use a helper function to move the two comparing potiners.\nBut the starting positions of the two pointers are tricky. \nWe start from the out-of-bound posi
Just use a helper function to move the two comparing potiners.\nBut the starting positions of the two pointers are tricky. \nWe start from the out-of-bound position from the end, and this simple trick can make the code concise.\n```\nclass Solution:\n    def backspaceCompare(self, s: str, t: str) -> bool:\n        def nextValid(string: str, i: int) -> int:\n            """\n            Given the index i, and the string, output the next valid position at the left.\n            When next valid position out of bound, return -1.\n            """\n            backspace = 0\n            while backspace >= 0:\n                i -= 1\n                if i < 0: return -1\n                if string[i] == "#": backspace += 1\n                else: backspace -= 1\n            return i\n        \n        p, q = len(s), len(t)  # two pointers starting from the end (which is out of bound)\n        while p >= 0 and q >= 0:\n            p, q = nextValid(s, p), nextValid(t, q)\n            if p >= 0 and q >= 0 and s[p] != t[q]: return False\n        return p < 0 and q < 0 \n```
['Two Pointers', 'Python']