Skip to content
Squarebrackets Private Limited
Squarebrackets
Courses
Browse
Explore
Services
Learning
Prep
Code&Run
Whiteboard
LMS
Problems

Merge Two Sorted Lists

Easy1 pt
Linked ListSortingTwo Pointers
PrerequisitesTwo Pointers, Linked List, Sorting
Merge two sorted lists into one sorted list. Input: line 1 = list A; line 2 = list B (space-separated). Output: the merged sorted list.
Example 1
Input
1 2 4
1 3 4
Output
1 1 2 3 4 4
Explanation
For the given input, the program prints exactly this output.
Example 2
Input
1 5
2 3 6
Output
1 2 3 5 6
Explanation
A second case — verify your logic handles it too.
Hints
Video
8 lines
Input (stdin)
Expected output · optional
Run checks your code against every example, one by one — all must pass. Type your own input above to run that instead (Run compares it to the expected output if you set one). The full suite is checked on Submit — a failing case reveals its input & expected output.