题解 | #明明的随机数#

明明的随机数

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))
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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