Linear time in-place merge with O(1) extra space