📌 C++ || Beats - 100% 💯💯|| Explained Using Stack
Easy And Beginner Friendly Approach\n\n    Runtime - 100%\uD83D\uDD25 \n\n# Approach\n1. We will store all the characters of both the string in stack, but when 
# Easy And Beginner Friendly Approach\n\n    Runtime - 100%\uD83D\uDD25 \n\n# Approach\n1. We will store all the characters of both the string in stack, but when doing so if we encounter \'#\' we will pop the top of stack.\n2. At last we will store both the strings and copare both.\n3. If equal return True, else return False.\n\n# Complexity\n- Time complexity: O(N)\n- Space complexity: O(N)\n\n#  If you like the solution and understand it then Please Upvote.\u2B06\uFE0F\u2764\uFE0F \n\t* PEACE OUT LUV\u270C\uFE0F*\n\n# Code\n```\nclass Solution {\npublic:\n    bool backspaceCompare(string s, string t) {\n        int n1 = s.length();\n        int n2 = t.length();\n        stack<int>st1;\n        stack<int>st2;\n        for(int i=0; i<n1; i++){\n            if(s[i]==\'#\'){\n                if(!st1.empty()){\n                    st1.pop();\n                }      \n            }else{\n                st1.push(s[i]);\n            }\n        }\n        for(int i=0; i<n2; i++){\n            if(t[i]==\'#\'){\n                if(!st2.empty()){\n                    st2.pop();\n                }  \n            }else{\n                st2.push(t[i]);\n            }\n        }\n        s.clear(); t.clear();\n        while(!st1.empty()){\n            s+=st1.top();\n            st1.pop();\n        }\n        while(!st2.empty()){\n            t+=st2.top();\n            st2.pop();\n        }\n        if(s==t)return true;\n        return false;\n    }\n};\n```
['String', 'Stack', 'C++']