rewrite median of two sorted arrays