@@ -0,0 +1,1405 @@
+/**%0A * There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median %0A * of the two sorted arrays. The overall run time complexity should be O(log (m+n)).%0A * @author Jun%0A */%0A%0Apublic class Solution %7B%0A    public double findMedianSortedArrays(int%5B%5D nums1, int%5B%5D nums2) %7B%0A    %09int m = nums1.length, n = nums2.length;%0A    %09if((m+n)%252 == 1)%0A    %09%09return getKth(nums1, nums2, (n+m)/2, 0, m-1, 0, n-1);%0A    %09else%0A    %09%09return 0.5*(getKth(nums1, nums2, (n+m)/2, 0, m-1, 0, n-1) + getKth(nums1, nums2, (n+m)/2-1, 0, m-1, 0, n-1));%0A    %7D%0A    %0A    // get the kth element in the union of x and y; k starts from 0%0A    private double getKth(int%5B%5D x, int%5B%5D y, int k, int xStart, int xEnd, int yStart, int yEnd) %7B%0A    %09 int xLength = xEnd - xStart + 1; %0A    %09 int yLength = yEnd - yStart + 1;%0A    %09 if(xLength == 0)   return y%5ByStart + k%5D;%0A    %09 if(yLength == 0)   return x%5BxStart + k%5D;%0A    %09 if(k == 0)         return Math.min(x%5BxStart%5D, y%5ByStart%5D);%0A    %09 %0A    %09 int xMid = xLength * k / (xLength + yLength);%0A    %09 int yMid = k - xMid - 1;%0A    %09 %0A    %09 xMid = xMid + xStart;%0A    %09 yMid = yMid + yStart;%0A    %09 %0A    %09 if(x%5BxMid%5D %3E y%5ByMid%5D) %7B%0A    %09%09 k = k - (yMid - yStart + 1);%0A    %09%09 xEnd = xMid;%0A    %09%09 yStart = yMid + 1;%0A    %09 %7D else %7B%0A    %09%09 k = k - (xMid - xStart + 1);%0A    %09%09 yEnd = yMid;%0A    %09%09 xStart = xMid + 1;%0A    %09 %7D%0A    %09 return getKth(x, y, k, xStart, xEnd, yStart, yEnd);%0A    %7D%0A%7D%0A

Create 004.java