function removeAdjacentDuplicates(s) {
const stack = [];
for (const ch of s) {
if (stack.length > 0 && stack[stack.length - 1] === ch) {
stack.pop(); // pop
} else {
stack.push(ch); // push
}
}
return stack.join('');
}
const s = "abbacccada";
console.log(removeAdjacentDuplicates(s));
/*
run:
cada
*/