Your question is Merge K Sorted Linked Lists. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
At Meta, imagine multiple pre-sorted event streams need to be combined into one ordered feed. Given k sorted singly linked lists, merge them into one sorted linked list and return its head.
Implement a function that takes lists, where lists[i] is the head of a sorted singly linked list or null. Each node contains an integer value and a next pointer. Return the head of a new merged sorted linked list formed by reusing the existing nodes.
def merge_k_lists(lists):