package algorithm.array;

/**
 * Created by allen on 16-11-19.
 */
public class MedianOfTwoSortedArrays {
}

@@ -30,79 +30,1224 @@
 %0A * 
-Created by allen on 16-11-19.%0A */%0Apublic class MedianOfTwoSortedArrays %7B
+%3Ch1%3E4. Median of Two Sorted Arrays%3C/h1%3E%0A * %3Cp%3E%0A *     There are two sorted arrays nums1 and nums2 of size m and n respectively.%0A *     Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).%0A * %3C/p%3E%0A * url: https://leetcode.com/problems/median-of-two-sorted-arrays/%0A */%0Apublic class MedianOfTwoSortedArrays %7B%0A%0A    public double findMedianSortedArrays(int%5B%5D nums1, int%5B%5D nums2) %7B%0A        if(nums1 == null %7C%7C nums2 == null) %7B%0A            return 0.0;%0A        %7D%0A%0A        int len1 = nums1.length;%0A        int len2 = nums2.length;%0A        int%5B%5D nums3 = new int%5Blen1 + len2%5D;%0A        int i1 = 0, i2 = 0, i = 0;%0A        while (i1 %3C len1 && i2 %3C len2) %7B%0A            if(nums1%5Bi1%5D %3C nums2%5Bi2%5D) %7B%0A                nums3%5Bi++%5D = nums1%5Bi1++%5D;%0A            %7D else %7B%0A                nums3%5Bi++%5D = nums2%5Bi2++%5D;%0A            %7D%0A        %7D%0A%0A        while(i1 %3C len1) %7B%0A            nums3%5Bi++%5D = nums1%5Bi1++%5D;%0A        %7D%0A        while(i2 %3C len2) %7B%0A            nums3%5Bi++%5D = nums2%5Bi2++%5D;%0A        %7D%0A%0A        int mid = nums3.length / 2;%0A        if(nums3.length %25 2 == 0) %7B%0A            return (double) (nums3%5Bmid - 1%5D + nums3%5Bmid%5D) / 2.0;%0A        %7D else %7B%0A            return (double) nums3%5Bmid%5D;%0A        %7D%0A    %7D
 %0A%7D%0A

add median of two sorted arrays answer.