Given the heads of two sorted linked lists, merge them into a single sorted list by splicing together the nodes of the two lists, and return the head of the merged list.
list1 = [1,2,4], list2 = [1,3,4][1,1,2,3,4,4]list1 = [], list2 = [][]Try it now — no sign-up needed. Write your solution in Python or JavaScript, run it against test cases, and submit for a verdict, right in your browser.
Open the editor →A chain of nodes, each pointing to the next. No random access like an array, but insertion and deletion at a known position is O(1), and many classic problems come down to careful pointer rewiring.
Read the full Linked List guide →
Original problem on LeetCode ↗