题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
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 arr = []; max = 0; str = ""; num = 0; for (let i = 0; i < line.length; i++) { if (!isNaN(line[i])) { str = str.concat(line[i]); num++; } if ((isNaN(line[i]) && num !== 0) || i === line.length - 1) { if (num > max) { arr = []; arr.push(str); max = num; } else if (num === max) { arr.push(str); } str = ""; num = 0; } } console.log(arr.join("").concat(",", max)); } })();