From 93c0e28b3bd4b269674955db12c4a2fb07f050de Mon Sep 17 00:00:00 2001 From: ussamaawan <91910265+ussamaawan@users.noreply.github.com> Date: Sun, 18 Sep 2022 22:02:33 +0500 Subject: [PATCH] Update solution.py --- Q3/solution.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Q3/solution.py b/Q3/solution.py index 18ab591..f54f93a 100644 --- a/Q3/solution.py +++ b/Q3/solution.py @@ -1,3 +1,18 @@ -class Solution: - def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float: - +# first we need to sort two arrays using time complexity +a=[] +b=[] +# using for loop and time +for each x in b + insert x into a + or q from 1 to m + if q == 1 then insert b[q] into a + else + insert b[q] into a starting from the position of b[q-1] + return length + #Now we have merged array length we can easily find median for odd and even case + length =len (merged_array) + if length % 2 == 0 : + med = (merged_array[(length/2)-1] + merged_array [length/2]/2 + else : + med =merged_array [int(length/2)] +