Suppose there is an array, we want to find everything in the odd index (index starting with 0), and move it to the end. Everything in the even index move it to the beginning. The relative order of all odd index items and all even index items are preserved.
i.e. if the array is
a1 b1 a2 b2 ... an bn
after the operation it becomes
a1 a2 a3 ... an b1 b2 ... bn
Can this be done in-place and in O(n) time?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With