Question bank › Linked List
Dsa Linked List Warm-up

Alternate Merge Linked Lists

You have two linked lists that contain sorted non-negative integer values. Your task is to merge the two linked lists such that the merged list maintains the sorted order and takes alternate nodes from each list. If one list is longer than the other, append the remaining nodes at the end of the merged list. Each linked list node is represented as a space-separated integer. Input format: - The first line contains integers representing the first linked list (space-separated) and ends with -1. - The second line contains integers representing the second linked list (space-separated) and ends with -1. Output format: - A single line of space-separated integers representing the merged linked list. Example: Input: 1 3 5 -1 2 4 6 8 -1 Output: 1 2 3 4 5 6 8

Key concepts

linked_listmergingiterative

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.