We have an array that is even placed sorted and oddly placed sorted, meaning that the sub-array with even indexes is sorted and the sub-array with odd indexes is sorted.
for example - {1,4,2,7,4,18,5,19,20}
the two sorted subarray are {1,2,4,5,20}
and {4,7,18,19}
- one group with the even indexes and the other with odd indexes.
Is there a way to sort this uniquely sorted array with O(1)
space complexity and O(n)
time? (meaning to rearrange it to be normally sorted)