✅Simple Java Solutions || ✅Runtime 2ms
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# Code1\n```Java\nclass Solution {\n    public boolean backspaceCompare(String s, String t) {\n        Stack<Character> str1 = new Stack<>();\n        Stack<Character> str2 = new Stack<>();\n        \n        for (char c : s.toCharArray() )\n        {\n            if (c == \'#\'){ \n                if (!str1.isEmpty()) str1.pop();\n            }else str1.push(c);\n        }\n        for (char c : t.toCharArray() )\n        {\n            if (c == \'#\'){\n                if (!str2.isEmpty()) str2.pop();\n            }else str2.push(c);\n        }\n\n        StringBuilder res1 = new StringBuilder();\n        StringBuilder res2 = new StringBuilder();\n        \n        while(!str1.isEmpty())\n            res1.append(str1.pop());\n        \n        while(!str2.isEmpty())\n            res2.append(str2.pop());\n        \n        return res1.toString().equals(res2.toString());\n    }\n}\n\n```\n\n\n\n# Code2\n```Java\nclass Solution {\n    public boolean backspaceCompare(String s, String t) {\n        return processString(s).equals(processString(t));\n    }\n\n    public String processString(String str) {\n        StringBuilder result = new StringBuilder();\n\n        for (char c : str.toCharArray()) {\n            if (c == \'#\') {\n                if (result.length() > 0) {\n                  // Apply backspace by removing the last character.\n                    result.deleteCharAt(result.length() - 1);\n                }\n            } else {\n                result.append(c);\n            }\n        }\n\n        return result.toString();\n    }\n}\n\n```\n## For additional problem-solving solutions, you can explore my repository on GitHub: [GitHub Repository](https://github.com/ahmedna126/java_leetcode_challenges)\n\n\n\n![abcd1.jpeg](https://assets.leetcode.com/users/images/ec37b533-cb1f-4dc2-82d9-f26dca556b9d_1697782265.9652042.jpeg)\n
['String', 'Stack', 'Java']