← AlgoMindset 75

Odd Even Linked List

Medium🎙 Interview me on this

🧠 Before you code — what pattern fits?

Given the head of a singly linked list, group all the nodes at odd positions together followed by the nodes at even positions (1-indexed), keeping relative order within each group. Solve in O(1) space and O(n) time.

[1,2,3,4,5] → [1,3,5,2,4]

[2,1,3,5,6,4,7] → [2,3,6,7,1,5,4]

🎬 Video explanation · Nick White

Your solution runs against 3 unit tests, including edge and large-value cases.

Loading...

Test console · 3 unit tests

Submit your code to run it against all 3 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.