Your question is Coding: Linked List Merge. 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.
A GE HealthCare Edison imaging workflow may maintain sorted linked lists of work items from two processing streams. Given the heads of two singly linked lists sorted in nondecreasing order, merge them into one sorted linked list.
Implement merge_sorted_lists(l1, l2), where l1 and l2 are either ListNode objects or None. Each ListNode has an integer val field and a next field. Return the head of the merged list. Reuse the existing nodes rather than creating nodes for every output value. If values are equal, either source list may be selected first.
For the JSON test cases, each input list is represented by an array of node values, and the expected result is the merged array of values.
def merge_sorted_lists(l1, l2):