题解 | 明明的随机数

明明的随机数

https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0

const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});
let n = null;
const inputs = [];

rl.on("line", (line:any) => {
    inputs.push(line)
}).on("close", () => {
    // let uniqueSorted = Array.from(new Set(inputs.slice(1)))
    //     .filter((x) => x >= 1 && x <= 500)
    //     .sort((x, y) => x - y);
    // console.log(uniqueSorted.join("\n"));
    let uniqueSorted = Array.from(new Set(inputs.slice(1)))
    .filter((x:any)=> x>=1&&x<=500)
    .sort((x:any,y:any)=>x-y)
    console.log(uniqueSorted.join('\n'))
});

全部评论

相关推荐

06-07 00:00
已编辑
腾讯_后端开发
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 17:51
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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