diff --git a/Java/Leetcode-Median-of-2-sorted-arrays.java b/Java/Leetcode-Median-of-2-sorted-arrays.java new file mode 100644 index 00000000..b290667e --- /dev/null +++ b/Java/Leetcode-Median-of-2-sorted-arrays.java @@ -0,0 +1,60 @@ +// Problem link : https://leetcode.com/problems/median-of-two-sorted-arrays/description + +class Solution { +public double findMedianSortedArrays(int[] nums1, int[] nums2) { +int arr[]=new int[nums1.length+nums2.length]; + + int j=0; + int i=0; + int r=0; + while(inums2[j]) + { + arr[r]=nums2[j]; + j++; + r++; + } + else + { + arr[r]=nums1[i]; + r++; + arr[r]=nums2[j]; + r++; + i++; + j++; + } + + } + while(i