题解 | #点击消除#
点击消除
https://www.nowcoder.com/practice/8d3643ec29654cf8908b5cf3a0479fd5
const rl = require("readline").createInterface({ input: process.stdin }); var iter = rl[Symbol.asyncIterator](); const readline = async () => (await iter.next()).value; void (async function () { // Write your code here while ((line = await readline())) { let stack = []; for (let i = 0; i < line.length; i++) { if (line[i] === stack[stack.length - 1]) { stack.pop(); } else { stack.push(line[i]); } } if (stack.length == 0) { console.log("0"); } else { console.log(stack.join("")); } } })();