Skip to content

Merge two sorted linked lists ​

Merge two sorted linked lists — LeetCode

Merge two sorted linked lists into a single sorted list by splicing the existing nodes together.

Approach ​

Merge two while checking for lesser one. Use a dummy head at start. Once the first while loop exits, assign whichever list is not null to the tail.

Remarks ​