685. Odd Even List
Om has a singly linked list where nodes with odd indices are grouped together, followed by nodes with even indices. Print the reordered list. The first node is considered odd, the second node is even, and so on. Note that the relative order within both the even and odd groups should remain the same as in the input. You must solve the problem using O(1) extra space complexity and O(n) time complexity.
The first line contains the size of the linked list. The second line contains the elements of the linked list.
Print the reordered linked list.
5 3 5 6 7 8
3 6 8 5 7
The linked list contains between 0 and 10^4 nodes. Each node's value is between -10^6 and 10^6.