median of two arrays-efficient way