Problems > Reverse Every Other Chunk > Editorial

Reverse Every Other Chunk — Solution & Editorial

Back to the Problem

Iterate in strides of 2K, reversing the [i, i+K) slice — slicing gracefully handles the ragged tail.

Complexity: O(|S|)