题解 | #明明的随机数#

明明的随机数

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


const lists = []
// 先读取所有行数再处理
while(line = readline()){
    lists.push(+line)
}

let length = lists.length
while(length > 0){
    handleList(lists)
    length = lists.length
}

 /* 分治 */ 
function handleList(list){
    const count = list.shift();
    const arr = list.splice(0, count)
    sortnPrint(arr)
}

/* 数组排序输出 */
function sortnPrint(arr){
    return [...new Set(arr)].sort((a,b)=>a-b).forEach( v=>print(v))
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
03-19 10:38
实力求职者:真的绷不住了,第一张霸总人设,第二张求生欲拉满
点赞 评论 收藏
分享
04-15 09:59
门头沟学院 C++
yy_11:小公司人家没必要泄密,大公司都是本地部署了
你想吐槽公司的哪些规定
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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