题解 | #明明的随机数#
明明的随机数
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 let n = 0; const initArr = []; let newArr = []; while ((line = await readline())) { if (n === 0) { n = Number(line); } else { initArr.push(Number(line)); if(initArr.length===n){ newArr = [...new Set(initArr)]; //数组去重 newArr.sort((a, b) => { return a - b; }); } newArr.forEach((x)=>{ console.log(x); }) } } })();