题解 | #明明的随机数#

明明的随机数

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

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
	// 1、使用 Set 去重并转化为数组
	// 2、使用 sort 排序并输出
    let numsSet = new Set();
    let count = 0;
    // let N;
    while ((line = await readline())) {
        count++;
        if (count == 1) {
            // N = line;
            continue;
        }
        numsSet.add(line);
    }
    let nums = Array.from(numsSet).sort((a, b) => { return a - b });
    for(let i = 0; i < nums.length; i++) {
        console.log(nums[i]);
    }
})();

全部评论

相关推荐

tttk_:就是人多。 有的是条件和你差不多然后没在od待过的人。 所以就拿这个筛你了。 就和卡学历一样,人太多了。 从公司角度,这样做节省精力,更方便。 没办法谁叫现在人多呢
第一份工作能做外包吗?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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