✅ JS || With explanation || Easy to Understand || Fast
I just found this Blog and Github repository with solutions to Leetcode problems.\nhttps://leet-codes.blogspot.com/2022/09/1047-remove-all-adjacent-duplicates-i
I just found this Blog and Github repository with solutions to Leetcode problems.\nhttps://leet-codes.blogspot.com/2022/09/1047-remove-all-adjacent-duplicates-in.html\nIt is very useful, and I just wanted to share it with you.\nNote: You can bookmark it as a resource, and for another approaches\n<br>\n\n```\n/**\n * @param {string} s\n * @return {string}\n */\nvar removeDuplicates = function(s) {\n   const stack = [];\n\tfor (let i = 0; i < s.length; i++) {\n\t\tconst cv = s[i];\n\t\tconst top = stack[stack.length - 1];\n\n\t\t// if last element is same as current pop off from stack\n\t\tif (cv === top) stack.pop();\n\t\telse stack.push(cv); // if not equal, add to stack\n\t}\n\n\treturn stack.join(\'\');\n};\n```\n
['Stack', 'TypeScript', 'JavaScript']