Question bank › Linked List
Dsa Linked List Hard

Rearrange Linked List Alternating Even and Odd

Given a linked list, rearrange it such that all odd-indexed nodes are grouped together and all even-indexed nodes are grouped together, while retaining the original order of appearance for both groups. Input format: - The first line contains an integer n (1 <= n <= 1000), the number of nodes. - The next n lines each contain a single integer value representing the node's value. Output format: - Output the rearranged linked list as space-separated integers. Example: Input: 5 1 2 3 4 5 Output: 1 3 5 2 4

Key concepts

linked_listrearrangementparity

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.