Given a sequence of interconnected nodes, rearrange the nodes such that the sequence alternates between nodes from the first half and nodes from the second half of the original sequence, effectively creating an interleaved reversal.
Explanation: The first half of the sequence is 1 -> 2 -> 3 and the second half is 4 -> 5 -> 6. Interleaving them results in 1 -> 4 -> 2 -> 5 -> 3 -> 6.
Explanation: The first half of the sequence is 7 and the second half is 8 -> 9. Interleaving them results in 7 -> 9 -> 8.
In-place reversal of node links
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak