C++  🥞🥞🥞 STACK 🥞🥞🥞
Use a stack\nIterate thru the string\nif the char is a \'#\', pop the stack if not empty.\n\ncompare s and t final strings\n\nSolved LIVE on stream.  Link in pr
Use a stack\nIterate thru the string\nif the char is a \'#\', pop the stack if not empty.\n\ncompare s and t final strings\n\n**Solved LIVE on stream.  Link in profile**\n```\nclass Solution {\npublic:\n    bool backspaceCompare(string s, string t) {\n        string sFinal = processString(s);\n        string tFinal = processString(t);\n        return sFinal == tFinal;\n    }\n    \nprivate: \n    string processString(string s) {\n        stack<char> stk;\n        for(char c : s) {\n            if(c == \'#\') {\n                if(!stk.empty())stk.pop();\n            } else {\n                stk.push(c);\n            }\n        }\n        string processed = "";\n        while(!stk.empty()) {\n            processed += stk.top();\n            stk.pop();\n        }\n        return processed;\n    }\n};\n```
[]