2 ways || Stack  100% faster || O(1) Space- Without Stack 100% faster  || Easy || CPP
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n// 1. With stack\nclass Solution {\npublic:\n    bool backspaceCompare(string s, string t) {\n        stack<char>st;\n\n        for(auto it:s){\n            if(it==\'#\'){\n                if(st.empty()==1){\n                    continue;\n                }\n                st.pop();\n            }\n            else{\n                st.push(it);\n            }\n        }\n        string s1="";\n        while(st.empty()==0){\n            s1.push_back(st.top());\n            st.pop();\n        }\n        \n        for(auto it:t){\n            if(it==\'#\'){\n                if(st.empty()==1){\n                    continue;\n                }\n                st.pop();\n            }\n            else{\n                st.push(it);\n            }\n        }\n\n        string s2="";\n        while(st.empty()==0){\n            s2.push_back(st.top());\n            st.pop();\n        }\n\n        return s1==s2;\n\n    }\n};\n\n\n\n\n\n// 2. Without Stack 2 pointer \nclass Solution {\npublic:\n    bool backspaceCompare(string s, string t) {\n        int n=s.size()-1;\n        int m=t.size()-1;\n        while(1){\n            int todel=0;\n            while(n>=0 && (todel>0 || s[n]==\'#\')){\n                if(s[n]==\'#\'){\n                    todel++;\n                }\n                else{\n                    todel--;\n                }\n                n--;\n            }\n\n            todel=0;\n            while(m>=0 &&(todel>0 || t[m]==\'#\')){\n                if(t[m]==\'#\'){\n                    todel++;\n                }\n                else{\n                    todel--;\n                }\n                m--;\n            }\n\n            if(n>=0 && m>=0 && s[n]==t[m]){\n                    n--;\n                    m--;\n            }\n                else{\n                    break;\n                }\n            \n        }\n\n\n        if(n==-1 && m==-1){\n            return 1;\n        }\n        return 0;\n    }\n};\n```
['String', 'Stack', 'C++']