@@ -0,0 +1,1102 @@
+package leetcode;%0A%0Apublic class Task4 %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        int%5B%5D nums1 = %7B1, 2%7D;%0A        int%5B%5D nums2 = %7B3, 4%7D;%0A        System.out.println(new Task4().findMedianSortedArrays(nums1, nums2));%0A    %7D%0A%0A    public double findMedianSortedArrays(int%5B%5D nums1, int%5B%5D nums2) %7B%0A        int%5B%5D mergedNums = merge(nums1, nums2);%0A        int mid = mergedNums.length / 2;%0A        return mergedNums.length %25 2 == 0 ? ((double) mergedNums%5Bmid%5D + mergedNums%5Bmid - 1%5D) / 2 : mergedNums%5Bmid%5D;%0A    %7D%0A%0A    private static int%5B%5D merge(int%5B%5D a, int%5B%5D b) %7B%0A        int aIndex = 0;%0A        int bIndex = 0;%0A        int%5B%5D merged = new int%5Ba.length + b.length%5D;%0A        for (int i = 0; i %3C merged.length; i++) %7B%0A            int aValue = aIndex %3C a.length ? a%5BaIndex%5D : Integer.MAX_VALUE;%0A            int bValue = bIndex %3C b.length ? b%5BbIndex%5D : Integer.MAX_VALUE;%0A            if (aValue %3C= bValue) %7B%0A                merged%5Bi%5D = aValue;%0A                aIndex++;%0A            %7D else %7B%0A                merged%5Bi%5D = bValue;%0A                bIndex++;%0A            %7D%0A        %7D%0A        return merged;%0A    %7D%0A%7D%0A

Add Task4