← Return

Merge Two Sorted Linked ListsEasy

This challenge is part of a tutorial track by MyCodeSchool

Given pointers to the heads of two sorted linked lists, merge them into a single, sorted linked list. Either head pointer may be null meaning that the corresponding list is empty.

Example

\(headA\) refers to \(1 \to 3 \to 7 \to NULL\)

\(headB\) refers to \(1 \to 2 \to NULL\)

The new list is \(1 \to 1 \to 2 \to 3 \to 7 \to NULL\)