题解 | #在字符串中找出连续最长的数字串#

在字符串中找出连续最长的数字串

https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec

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 map = [];
        line.replace(/\d+/g,(res)=>{
            if(map[res.length]){
                map[res.length].push(res)
            }else {
                map[res.length] = [res]
            }
        
        })
       console.log(map[map.length-1].reduce((acc,item)=>(acc+item),"") + "," + (map.length-1))  
    }
}()

全部评论

相关推荐

沉淀去了,8月是不是机会会多一点,。打招呼300+,就一个小厂面试,聊了十分钟天就让我去了,暑假继续沉淀了,到八月九月冲了
丰川打工祥:我目前的体感是,双非本+一段小厂实习,基本约不到中厂的面。已经开始第二段小厂了。可能的确是最近hc太少了。
点赞 评论 收藏
分享
学历算污点吗?
小何和:快毕业了,BOSS上的od闻着味就来了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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