LeetCode 21. Merge Two Sorted Lists (Java)

Description

https://leetcode.com/problems/merge-two-sorted-lists/description/

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.

Example:

Explanation

 

We compare the pointer to l1, l2 linked list node one by one. The smaller list node would be added to the new linked list.

Video Tutorial

Java Solution

3 thoughts

Leave a Reply

Your email address will not be published. Required fields are marked *