Grokking Data Structures & Algorithms for Coding Interviews
0% completed
Stretch Problem: Odd Even Linked List (medium)
This problem is optional. The problems above cover what the chapter teaches. This one is here for readers who want a harder linked list question, and nothing later in the course depends on it.
Problem Statement
You are given the head of a singly linked list. Group all the nodes in odd positions together, followed by all the nodes in even positions, and return the head of the result.
Positions are counted from 1, so the first node is in an odd position. The position is about where a node sits in the list, not about the value it holds
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%