题解 | #合并k个已排序的链表#

合并k个已排序的链表

https://www.nowcoder.com/practice/65cfde9e5b9b4cf2b6bafa5f3ef33fa6

Firstly, we define a result linkedlist by malloc.

Secondly, we set while(1), then traverse the list and record the node with smallest val, and record the index k of the linkedlist.

Thirdly, once we find the node with smallest val, then we append the node to the result linkedlist, and set the head of the linkedlist with index k to list[k] = list[k]->next

Finally, we stop the while loop whenever node with smallest val == NULL, which means no more node can be extracted from the list. Afterward, return the second node of result linkedlist, cuz first node is useless.

#链表排序#
全部评论

相关推荐

翱翔龙骑:耗材的幻想
点赞 评论 收藏
分享
06-11 13:34
门头沟学院 C++
offe从四面八方来:我真的没时间陪你闹了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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