
Leetcode Problem 1047: Remove All Adjacent Duplicates In String
Given a string s, repeatedly remove all adjacent duplicate pairs until no more exist. Return the final string. The order of removal does not affect the result.
Constraints:
function removeDuplicates(s: string): string {
let stack: string[] = []
for(let i = 0; i < s.length; i++) {
let currentChar = s.charAt(i)
if (stack[stack.length - 1] !== currentChar) {
stack.push(currentChar)
} else {
stack.pop()
}
}
return stack.join("")
};