Python - Adding two List, Sorting it and then finding the median.


  • -1
    class Solution(object):
        def findMedianSortedArrays(self, nums1, nums2):
            nums3 = nums1 + nums2
            nums3.sort()
            if((len(nums3)%2) == 0):
                print(nums3[int((len(nums3))/2)-1])
                return (float((nums3[int((len(nums3))/2)]+nums3[int((len(nums3))/2)-1]))/2)
            else:
                return nums3[(len(nums3))/2]
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.