Python solution with two pointers, O(N) time and O(1) space
Intuition\nWe can work from the back to simulate the "backspacing." By counting the number of backspaces, we can figure out the next character in the string tha
# Intuition\nWe can work from the back to simulate the "backspacing." By counting the number of backspaces, we can figure out the next character in the string that will remain after in the final result.\n\n# Approach\nWe iterate through each string going from back to front because the backspace # symbol deletes characters proceeding it.\n\nTo avoid duplicate code, we write a helper method that counts the number of #s to figure out what the next character from the back that remains in the string would be.\n\nThen, working from the back, we check to make sure the remaining character at each equivalent position is equal. If they are, we use the helper method to update the two pointers and check for equivalence again; if not, we return false.\n\nWhen we get to the end, we check to make sure each pointer has gotten to -1, i.e., both strings have been traversed completely. If so, we know that they will be equal after backspacing; if not, we know that they would not be. \n\n# Complexity\n- Time complexity:\nThe time complexity is O(N), as each string is traversed twice.\n\n- Space complexity:\nThe time complexity is O(1): we use two pointers in the main method, and the helper method uses one pointer. Each takes up constant space.\n\n# Code\n```python []\nclass Solution(object):\n    def backspaceCompare(self, s, t):\n        """\n        :type s: str\n        :type t: str\n        :rtype: bool\n        """\n\n        i_s = self.findNextChar(s, len(s) - 1)\n        i_t = self.findNextChar(t, len(t) - 1)\n\n        while i_s >= 0 and i_t >= 0:\n            if s[i_s] != t[i_t]:\n                return False\n            else:\n                i_s = self.findNextChar(s, i_s-1)\n                i_t = self.findNextChar(t, i_t-1)\n        \n        return i_s == -1 and i_t == -1\n\n\n    def findNextChar(self, str, i):\n        num_bs = 0\n        while(True):\n            if i == -1:\n                return -1\n            elif str[i] == \'#\':\n                num_bs += 1\n                i -= 1\n            elif num_bs > 0:\n                num_bs -= 1\n                i -= 1\n            else:\n                break\n        return i\n            \n```
['Python']