题解 | #点击消除#
点击消除
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 tokens = line.split(""); let arr = []; // console.log(tokens); for(let i of tokens) { if(i == arr[arr.length - 1]) { arr.pop(); }else { arr.push(i); } } console.log(arr.length == 0 ? '0' : arr.join("")); } }() // 看评论区大佬的思路就是强,自己写的太垃圾,还超时了
算法题合集 文章被收录于专栏
自己做算法的解题代码