param { number [ ] } nums1 param { number [ ] } nums2 return { number } var findMedianSortedArrays = function ( nums1 , nums2 ) { let len1 = nums1 . length ; let len2 = nums2 . length ; let left = Math . floor ( ( len1 + len2 + 1 ) / 2 ) ; let right = Math . floor ( ( len1 + len2 + 2 ) / 2 ) ; return ( findHelper ( nums1 , 0 , nums2 , 0 , left ) + findHelper ( nums1 , 0 , nums2 , 0 , right ) ) / 2.0 ; } ; param { number [ ] } nums1 param { number } i param { number [ ] } nums2 param { number } j param { number } target return { number } var findHelper = function ( nums1 , i , nums2 , j , target ) { if ( i >= nums1 . length ) return nums2 [ j + target - 1 ] ; if ( j >= nums2 . length ) return nums1 [ i + target - 1 ] ; if ( target === 1 ) { return nums1 [ i ] <= nums2 [ j ] ? nums1 [ i ] : nums2 [ j ] ; } let mid1 = ( i + target / 2 - 1 < nums1 . length ) ? nums1 [ i + Math . floor ( target / 2 ) - 1 ] : Number . MAX_VALUE ; let mid2 = ( j + target / 2 - 1 < nums2 . length ) ? nums2 [ j + Math . floor ( target / 2 ) - 1 ] : Number . MAX_VALUE ; if ( mid1 < mid2 ) { return findHelper ( nums1 , i + Math . floor ( target / 2 ) , nums2 , j , target - Math . floor ( target / 2 ) ) ; } else { return findHelper ( nums1 , i , nums2 , j + Math . floor ( target / 2 ) , target - Math . floor ( target / 2 ) ) ; } } ; export { findMedianSortedArrays } ;