You are given an array of k singly linked lists, where each linked list is sorted in non-decreasing order. Your task is to merge all the linked lists into one sorted linked list and return its head.
Example 1
Input: lists = [[1,4,5],[1,3,4],[2,6]]
Output: [1,1,2,3,4,4,5,6]
Explanation: All the sorted linked lists are merged into one sorted linked list.
Example 2
Input: lists = []
Output: []
Explanation: Since there are no linked lists, the result is an empty linked list.
Example 3
Input: lists = [[2],[1,3],[4,5]]
Output: [1,2,3,4,5]
Explanation: The nodes from all linked lists are merged while maintaining sorted order.
Sign in to write, run, and submit your solution against the full test suite.