LeetCode每日一练【4】
作者:互联网
LeetCode每日一练
median-of-two-sorted-arrays
const findMedianSortedArrays = (nums1, nums2) => {
const nums = [...nums1, ...nums2].sort((a, b) => {
return a - b;
});
const length = nums.length;
const median = Math.floor(length / 2);
return length % 2 === 1 ? nums[median] : (nums[median] + nums[median - 1]) / 2;
};
标签:...,const,nums,每日,median,nums1,length,LeetCode 来源: https://www.cnblogs.com/mapodoufu/p/16172553.html