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.
Java
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