← 返回 bytedance 的题目列表Merge k Sorted Lists
类型:online_judge
Merge k sorted linked lists.
Given k linked lists, each sorted in ascending order, merge all the lists into one sorted linked list and return its head. The algorithm should have a time complexity of O(N log k), where N is the total number of elements across all lists.
Example:
Input: [[1,4,5],[1,3,4],[2,6]]
Output: [1,1,2,3,4,4,5,6]
Constraints:
The total number of nodes across all lists is in the range [0, 10^4].
Each linked list's length is in the range [0, 500].
Node values are in the range [-10^4, 10^4].
k is in the range [1, 100].
Example
Input
[[1,4,5],[1,3,4],[2,6]]