rewrite leetcode median of two sorted arrays