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 // 方1 使用正则,会超时 let line = await readline(); // let str = ''; // while(str!==line){ // str = line; // line = line.replace(/([a-z])\1{1}/g,'') // } // console.log(str?str:0) //方2,遍历一次的方式 let arr = []; line = line.split(''); let len = line.length; arr[0] = line[0]; for(let i =1;i<len;i++){ if(line[i]===arr[arr.length-1]){ arr.pop() }else{ arr.push(line[i]) } } console.log(arr.length?arr.join(''):0) }()