Dsa
Linked List
Easy
Fold-and-Reverse Merge
Take a singly linked list and split it into two sub-lists: List A containing nodes at odd positions (1st, 3rd, 5th...) and List B containing nodes at even positions (2nd, 4th, 6th...). Reverse List B. Finally, merge them by alternating nodes starting with the first node of List A, then the first of reversed List B, etc.
Input:
A single line of space-separated strings.
Output:
The resulting interleaved list space-separated.
Example:
Input:
A B C D E F
Output:
A F C D E B
(A: A C E, B: B D F. Reverse B: F D B. Merge: A, F, C, D, E, B)
Key concepts
linked_listlist_splittingreversal
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