Python O(N) time, truly O(1) space solution without iterators
If you also feel that using iterators is a cheating then you may like this simple and fast solution that is based on two indexes:\n\n\n# IDEA: use two indexes t
If you also feel that using iterators is a cheating then you may like this simple and fast solution that is based on two indexes:\n\n```\n# IDEA: use two indexes to scan strings in reverse, on every step move indexes back by at least 1 but if # encountered keep moving farther backwards\n#       compare characters at indexes and return False if not equal; return True at the end if both strings were scanned fully\n#       O(N) time, O(1) space\n#\nclass Solution:\n    def backspaceCompare(self, S: str, T: str) -> bool:\n        i, j = len(S), len(T) # two indexes, start outside of string to make loop simpler\n        \n        while i >= 0 and j >= 0:\n            back = 1 # backspace counter, move back at least one character\n            while back > 0:\n                i -= 1\n                back += 1 if i >= 0 and S[i] == \'#\' else -1 # if hashtag found increase backspace counter, otherwise decrease it\n\n            back = 1\n            while back > 0:\n                j -= 1\n                back += 1 if j >= 0 and T[j] == \'#\' else -1\n            \n            if i >= 0 and j >= 0 and S[i] != T[j]: # done with backspaces, compare current character\n                return False\n        \n        return i < 0 and j < 0 # return True if both indexes passed both strings fully\n```
['Python', 'Python3']