You are given the heads of two sorted linked lists list1 and list2.
Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists.
Return the head of the merged linked list.
To simplify execution in the web runner, the linked lists are provided as JSON arrays.
list1list2Input:
[1,2,4]
[1,3,4]
Output: [1,1,2,3,4,4]
Input:
[]
[]
Output: []
Input:
[]
[0]
Output: [0]
Your program must print the merged list as a JSON array so it can be compared with the expected output.
No submissions yet.
Discuss iterative vs recursive merging, pointer manipulation, and edge cases like empty lists.