题解 | #合并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.
#链表排序#