An array has elements as [0th, 2nd, 4th, 6th, ..., 1st, 3rd, 5th, 7th, ...] where each Nth is the relative rank of the element; merge the two halves in-place (no extra memory) into ascending order.
Asked in the technical interview stage. Implement the operation for an even-length list whose two contiguous halves are individually sorted.
Implement def merge_ranked_halves(nums):. Modify nums in place and return it. Use O(1) auxiliary space.
def merge_ranked_halves(nums):