Javascript Solution with no iteration


  • -1
    K
    var findMedianSortedArrays = function(nums1, nums2) {
        let arr = nums1.concat(nums2);
        let median = 0;
        
        arr = arr.sort(function (a, b) { return a - b});
        let n = arr.length;
        if (n % 2 === 0) {
            median = (arr[n/2] + arr[n/2-1])/2;
        } else {
            median = arr[Math.floor(n/2)];
        }
        return median;
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.