2 pointer Approach | Detailed explanation with intuition | O(1) space | C++
A character can get erased if there is a backspace character just after it. It may also get erased if there are enough backspaces(greater than non backspace cha
* A character can get erased if there is a backspace character just after it. It may also get erased if there are enough backspaces(greater than non backspace character, so that non space ones are erased first and then the current one) after it. \n* So if there are less backspace character after it we can be sure that it will be in the final string.\n* In order to check if efficiently how many backspace character can be present after it we can maitain a suffix array of number of backspace characters after the ith index or just traverse the string in reverse.\n* If we find a backspace character the next character while traversing the string in reverse will be skipped.\n\n**C++**\n```\nbool backspaceCompare(string s, string t) {\n        int i = s.length()-1, j = t.length()-1; \n        int skips = 0, skipt = 0;\n        while(i>=0 || j>=0) {\n            while(i>=0) {\n                if(s[i] == \'#\') \n                    skips++, i--;\n                else if(skips>0)\n                    skips--, i--;\n                else break;\n            }\n            while(j>=0) {\n                if(t[j] == \'#\') \n                    skipt++, j--;\n                else if(skipt > 0) \n                    skipt--, j--;\n                else break;\n            }\n            if(i>=0 && j>=0 && s[i] != t[j]) return false;\n            // One string gets empty, unequal length string also result in false\n            if(i>=0 ^ j>=0) return false;\n            i--, j--;\n        }\n        return true;\n    }\n```
['Two Pointers']