As reported: Apple IS&T Reliability Engineering intern (India, 2025), round 1 — technical, about 50 minutes on CoderPad: merge K sorted linked lists, discussing the brute force against a min-heap.
You are given an array of k linked lists, each sorted in ascending order. Merge them into one sorted linked list and return it.
This is LeetCode 23 — Merge k Sorted Lists.
Example 1
lists = [[1,4,5],[1,3,4],[2,6]] -> [1,1,2,3,4,4,5,6]
Example 2
lists = [] -> []
lists = [[]] -> []
Constraints: 0 ≤ k ≤ 10^4; each list has 0 to 500 nodes; −10^4 ≤ val ≤ 10^4; each list is sorted ascending; the total number of nodes is at most 10^4.
Code runner format: one JSON value per line: lists as an array of arrays (LeetCode's test-case format). Implement mergeKLists(lists); the harness prints the merged list as an array.