Merge Two Sorted Linked Lists

00:00
EasyLinked ListTwo PointersRecursion
AmazonMicrosoftFlipkart

Merge two sorted linked lists into one sorted list by splicing nodes together. Return the merged head.

Examples

Input → 1
Output → 2->4 + 1->3->4 -> 1->1->2->3->4->4
Input → [] + []
Output → []
Input → [] + [0]
Output → [0]
Input → 1
Output → 3->5 + 2->4->6 -> 1->2->3->4->5->6