###### leetcode 4.Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).

public class Solution {
public double findMedianSortedArrays(int[] nums1, int[] nums2) {
double res = 0;
int len1 = nums1.length;
int len2 = nums2.length;
int len = len1 + len2;
int[] total = new int[len];
for(int i=0;i<len1;i++){
total[i] = nums1[i];
}
for(int j=0;j<len2;j++){
total[len1+j] = nums2[j];
}

Arrays.sort(total);
if(len%2==0){
res = (double) (total[len/2-1] + total[len/2])/2;
}else{
res = total[len/2];
}

return res;
}
}

#### leetcode: 4. Median of Two Sorted Arrays (java)

2016-06-20 20:44:18

#### 《LeetBook》leetcode题解(4): Median of Two Sorted Arrays[H]——两个有序数组中值问题

2016-04-09 21:24:06

#### leetcode之 median of two sorted arrays

2013-09-10 00:15:50

#### leetcode04-Median of Two Sorted Arrays-python

2016-03-31 15:11:13

#### LeetCode 4. Median of Two Sorted Arrays（两个有序数组的中位数）

2016-05-01 15:39:34

#### LeetCode（4）Median of Two Sorted Arrays

2015-08-22 20:35:01

#### 两个有序数组的中位数Median of Two Sorted Arrays（很重要）

2016-06-21 11:11:03

#### Median of Two Sorted Arrays 两个有序数组的中位数@LeetCode

2013-12-16 13:52:04

#### 【leetcode c++】21 Merge Two Sorted Lists

2015-06-18 13:37:28

#### leetcode之Median of Two Sorted Arrays问题

2017-06-29 18:49:50

## 不良信息举报

leetcode 4.Median of Two Sorted Arrays