diff --git a/Q3/solution.py b/Q3/solution.py index 18ab591..a203a13 100644 --- a/Q3/solution.py +++ b/Q3/solution.py @@ -1,3 +1,26 @@ class Solution: - def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: + def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: + i = 0 # Current index of input array ar1[] + j = 0 # Current index of input array ar2[] + n=len(nums1) + m=len(nums2) + m1, m2 = -1, -1 + for count in range(((n + m) // 2) + 1) : + if(i != n and j != m) : + if nums1[i] > nums2[j] : + m1 = nums2[j] + j += 1 + else : + m1 = nums1[i] + i += 1 + elif(i < n) : + m1 = nums1[i] + i += 1 + # for case when j