Odd Even Linked List
Expert Answer & Key Takeaways
A complete guide to understanding and implementing Linked List Patterns.
Odd Even Linked List
Group nodes with odd indices together followed by even indices.
Visual Representation
1 -> 2 -> 3 -> 4 -> 5
Odd: 1 -> 3 -> 5
Even: 2 -> 4
Result: 1 -> 3 -> 5 -> 2 -> 4Examples
Input: head = [1,2,3,4,5]
Output: [1,3,5,2,4]
Approach 1
Level I: Brute Force (Two Lists/Arrays)
Intuition
Traverse the list and store odd-indexed nodes in one list/array and even-indexed nodes in another. Then, link the end of the odd list to the head of the even list.
⏱ O(N)💾 O(N)
Detailed Dry Run
1->2->3->4.
Odd: [1, 3]. Even: [2, 4].
Result: 1->3->2->4.
Approach 2
Level III: Two Pointers (In-place)
Intuition
Maintain odd and even pointers, cross-linking as you traverse.
⏱ O(N)💾 O(1)
Course4All Technical Board
Verified ExpertSenior Software Engineers & Algorithmic Experts
Our DSA content is authored and reviewed by engineers from top tech firms to ensure optimal time and space complexity analysis.
Pattern: 2026 Ready
Updated: Weekly
Found an issue or have a suggestion?
Help us improve! Report bugs or suggest new features on our Telegram group.