题解 | #点击消除#

点击消除

http://www.nowcoder.com/practice/8d3643ec29654cf8908b5cf3a0479fd5

const str = readline();
    
const inarr = str.split("");

const arr = [];

for( let i = 0, l = inarr.length; i < l; i++ ) {
    
    const item = inarr[i];
    
    if( i > 0 && item === arr[arr.length - 1] ) {
        arr.pop()
    }else {
        arr.push( item )
    }
    
}

if( arr.length > 0 ) {
    print(arr.join(""))
}else {
    print(0)
}

全部评论
大哥,这怎么复制过去呢,我直接复制到node环境中报错
点赞 回复 分享
发布于 2022-10-19 22:18 江西

相关推荐

每晚夜里独自颤抖:你cet6就cet6,cet4就cet4,你写个cet证书等是什么意思。专业技能快赶上项目行数,你做的这2个项目哪里能提现你有这么多技能呢
点赞 评论 收藏
分享
06-18 13:28
已编辑
门头沟学院 Web前端
爱睡觉的冰箱哥:《给予你300的工资》,阴的没边了
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务