Java stack solution
\nclass Solution {\n    public boolean backspaceCompare(String S, String T) {\n        return compute(S).equals(compute(T));\n    }\n    \n    private Stack<Cha
```\nclass Solution {\n    public boolean backspaceCompare(String S, String T) {\n        return compute(S).equals(compute(T));\n    }\n    \n    private Stack<Character> compute(String S) {\n        Stack<Character> stack = new Stack();\n        for (char c : S.toCharArray()) {\n            if (c != \'#\') {\n                stack.push(c);\n            } else if (!stack.isEmpty()) {\n                stack.pop();\n            }\n        }\n        return stack;\n    }\n}\n```
[]