C++ | JavaScript
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```javascript []\nputs \'Hello world!\'\n\n/**\n * @param {string} s\n * @param {string} t\n * @return {boolean}\n */\nvar loopCheck = function(str) {\n    let res = "";\n    for(let i=0; i<str.length; i++) {\n        if(str[i]=="#") res = res.slice(0, -1);\n        else res = res + str[i];\n    }\n    return res;\n}\nvar backspaceCompare = function(s, t) {\n    console.log(loopCheck(s));\n    console.log(loopCheck(t));\n    if(loopCheck(s) == loopCheck(t)) return true;\n    else return false;\n};\n```\n```cpp []\nclass Solution {\npublic:\n    string loopCheck(string str) {\n        string res = "";\n        for(int i=0; i<str.size(); i++) {\n            if(str[i] == \'#\' && !res.empty()) res.erase(res.size()-1);\n            else if(str[i]!=\'#\') res = res + str[i];\n        }\n        return res;\n    }\n    bool backspaceCompare(string s, string t) {\n        return (loopCheck(s) == loopCheck(t)) ? true: false;\n    }\n};\n```
['C++', 'JavaScript']