// 输入:"abbaca"
// 输出:"ca"
var removeDuplicates = function (str) {
let stack = []
for (const s of str) {
let pre = stack.pop()
if (pre !== s) {
stack.push(pre)
stack.push(s)
}
}
return stack.join('')
}
console.log(removeDuplicates('abbaca'))