let n = parseInt(readline()); let ans = [] let reg1 = /([0-9a-zA-Z])\1{2}/g; let reg2 = /(.)\1(.)\2/g; for (let i = 0; i < n; i++) { let str = readline() let before = str.length let after = -1 while (before != after) { before = str.length if (str.match(reg1) != null) { str.match(reg1).forEach(element => { str = str.replace(element, element.slice(0, element.length - 1)) }); } after = str.length } before = str.length after = -1 while (before != after) { before = str.length if (str.match(reg2) != null) { str.match(reg2).forEach(element => { str = str.replace(element, element.slice(0, element.length - 1)) }); } after = str.length } ans.push(str) } for(let j = 0;j<ans.length;j++){ console.log(ans[j]) }
点赞 评论

相关推荐

把球:这个听过,你加了就会发现是字节的hr
点赞 评论 收藏
分享
牛客网
牛客企业服务