leetcode median of two sorted arrays - refactoring