Odd Even Linked List
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. The first node is considered odd, and the second node is even, and so on.
Odd Even Linked List

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. The first node is considered odd, and the second node is even, and so on.

Example 1:
Input: [1,2,3,4,5]
Output: [1,3,5,2,4]
Input
arr =[1,2,3,4,5]

Group odd-indexed nodes together followed by even-indexed nodes

Odd indices
Even indices
Current
Original List (1-indexed positions shown)
1(odd)
1

2(even)
2

3(odd)
3

4(even)
4

5(odd)
5
Odd-indexed nodes

Empty

Even-indexed nodes

Empty

Result

Building...

Variables
No variables to display
DepthFunction Call
Stack empty
0/7