Python - Easy Solution
Basic Solution: O( (m * 2M) + (n * 2N) ), where small m and n are the number of # in the strings S and T respectively, and M and N are length of strings S and T
**Basic Solution**: O( (m * 2M) + (n * 2N) ), where small m and n are the number of # in the strings S and T respectively, and M and N are length of strings S and T respectively. (Thanks @lewkoo)\n\n```\nclass Solution:\n    def backspaceCompare(self, S: str, T: str) -> bool:\n        S, T = self._helper(S), self._helper(T)\n        return S == T\n    \n    def _helper(self,s):\n        while "#" in s:\n            i = s.index("#")\n            s = s[:i-1] + s[i+1:] if i > 0 else s[i+1:]\n        return s\n```\n\n**Stack Based Optimised Solution: O(n)**\n\n```\nclass Solution:\n    def backspaceCompare(self, S: str, T: str) -> bool:\n        S, T = self._helper(S), self._helper(T)\n        return S == T\n    \n    def _helper(self,s):\n        stack = []\n        for ele in s:\n            if ele != "#":\n                stack.append(ele)\n            elif stack:\n                stack.pop()\n        return stack \n```
['Python3']