The Odd Even Linked List problem asks you to rearrange a linked list so that all odd-indexed nodes come before all even-indexed nodes (1-indexed), maintaining relative order within each group. This must be done in O(1) space and O(n) time. This coding problem is a classic linked list pointer manipulation exercise.
Apple, Microsoft, Meta, Amazon, Google, Bloomberg, and many others ask this because it tests in-place linked list rearrangement without extra space. Maintaining two sub-lists (odd and even) and connecting them is a fundamental linked list skill. The linked list interview pattern is the core.
Two-pointer list splitting. Maintain odd (pointer to last odd-indexed node) and even (pointer to last even-indexed node), plus evenHead (first even-indexed node). While even != null and even.next != null: connect odd to even.next (skip even node), advance odd; connect even to odd.next (skip next odd node), advance even. Finally, connect odd.next = evenHead.
List: 1→2→3→4→5.
evenHead pointer before the final connection.even and even.next).next pointers in wrong order (creates cycles).Linked list rearrangement problems follow the "split and reconnect" pattern: maintain separate pointers for each group, build each group incrementally, then connect at the end. The evenHead saved reference is the critical piece — never lose it before reconnection. Practice similar problems: "separate positive and negative nodes," "group by k," "reverse alternate k nodes."
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Reverse Linked List II | Medium | Solve | |
| Find the Minimum and Maximum Number of Nodes Between Critical Points | Medium | Solve | |
| Delete Node in a Linked List | Medium | Solve | |
| Split Linked List in Parts | Medium | Solve | |
| Merge In Between Linked Lists | Medium | Solve |