Coding Challenge

Merge Two Sorted Lists

Easy
linked-listrecursion

Merge two sorted linked lists into one sorted list.

You are given the heads of two sorted singly linked lists. Merge them into a single sorted linked list and return the merged head.

Examples

Input: list1 = [1,2,4], list2 = [1,3,4]

Output: [1,1,2,3,4,4]

Constraints

  • Lists may be empty
  • Values are already sorted in non-decreasing order

Preparing your coding workspace...