15% off all plans & roadmaps Use code
See plansLeetCode 328 · Solution & editorial
Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list.
Odd Even Linked List is a Linked List Manipulation Patterns problem, in the Reordering / Partitioning subpattern. The pattern covers in-place reversal, merging sorted lists, reordering, and intersection detection
Learn to reorder and partition linked lists. Master techniques like swap pairs, rotate list, and odd-even separation.
The reference solution runs in O(n) time and O(1) space.
Odd Even Linked List has been reported in interviews at Bloomberg, Oracle, Facebook, Google.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Odd Even Linked List is a Linked List Manipulation Patterns problem, in the Reordering / Partitioning subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.