JAVA | Stack | Explained | Easy solution
\n/*\nAlgorithm:\n1. Maintain two stacks for each of the two strings which contain the final\n   resultant strings of the same.\n2. Perform the `keyboard typing
```\n/*\nAlgorithm:\n1. Maintain two stacks for each of the two strings which contain the final\n   resultant strings of the same.\n2. Perform the `keyboard typing` action by iterating character by character \n   over the input strings and putting them into their respective stacks.\n3. During the above operation, if the `#` letter occurs, perform `pop()`\n   operation on the stacks if the stacks are not empty. Else perform `push()`\n   on the same.\n4. Thus the stacks are left with characters of resultant strings. \n5. Construct the strings from the stacks and return if they are same.\n*/\n\nclass Solution {\n    public boolean backspaceCompare(String s, String t) {\n        Stack<Character> s1 = new Stack<Character>();\n        Stack<Character> s2 = new Stack<Character>();\n        for(char ch : s.toCharArray()){\n            if(ch == \'#\'){\n                if(!s1.isEmpty())\n                    s1.pop();\n                continue;\n            }\n            s1.push(ch);\n        }\n        for(char ch : t.toCharArray()){\n            if(ch == \'#\'){\n                if(!s2.isEmpty())\n                    s2.pop();\n                continue;\n            }\n            s2.push(ch);\n        }\n        String res1 = "";\n        String res2 = "";\n        while(!s1.isEmpty())\n            res1 += s1.pop();\n        while(!s2.isEmpty())\n            res2 += s2.pop();\n        return res1.equals(res2);\n    }\n}\n```\nPlease do Upvote if you like the solution. :-)
['String', 'Stack', 'Java']