Algorithm · Reddit · Medium
Given the first node of a singly linked list, place every node at an odd 1-based position first, then append all nodes that were at even 1-based positions. Return the first node of the rearranged chain. Note: Odd and even describe a node’s position in the list, rather than the integer stored in that node. Input/Output Input: the list’s first node, head Output: the first node of the reordered list Constraints 0 6 -> 4 -> 2 -> 0 Output: 8 -> 4 -> 0 -> 6 -> 2 Input: 9 -> 8 -> 7…
Checking your access…