题解 | 字符串中找出连续最长的数字串
字符串中找出连续最长的数字串
https://www.nowcoder.com/practice/bd891093881d4ddf9e56e7cc8416562d
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
let params = []
while(line = await readline()){
let tokens = line.split(' ');
// let a = parseInt(tokens[0]);
// let b = parseInt(tokens[1]);
// console.log(a + b);
params.push(tokens)
}
// console.log(params)
let str = params[0][0]
let matches = str.matchAll(/[0-9]+/g)
let maxStr = ""
for(match of matches){
// console.log(match)
let str = match[0]
if(str.length > maxStr.length){
maxStr = str;
}
}
console.log(maxStr)
}()

查看29道真题和解析