Easy Solution Using STACK ✅|| JAVA  💯
\n# Complexity\n- Time complexity:\nO(log n)\n\n\n# Code\n\nclass Solution {\n    public boolean backspaceCompare(String s, String t) {\n\n        Stack<Charact
\n# Complexity\n- Time complexity:\nO(log n)\n\n\n# Code\n```\nclass Solution {\n    public boolean backspaceCompare(String s, String t) {\n\n        Stack<Character> st=new Stack<>();\n        Stack<Character> st2=new Stack<>();\n\n        for(char c:s.toCharArray()){\n            if(c==\'#\')\n            {   \n                if(!st.isEmpty())\n                st.pop();\n            }else\n                st.push(c);\n        }\n        \n        for(char c:t.toCharArray()){\n            if(c==\'#\'){\n                if(!st2.isEmpty())\n                    st2.pop();}\n            else\n                st2.push(c);\n            \n        }\n        if(st.equals(st2)){\n            return true;\n        }\n    return false;\n    }\n}\n```\n\n![7abc56.jpg](https://assets.leetcode.com/users/images/9fc0dd3b-6e5e-4e0b-98bb-245d80bc8d9a_1677219761.450169.jpeg)\n
['String', 'Stack', 'Java']