Simple solution, please critique


  • 0
    S

    This simple solution works. Please critique

    def findMedianSortedArrays(self, nums1, nums2):
            """
            :type nums1: List[int]
            :type nums2: List[int]
            :rtype: float
            """      
            nums = nums1 + nums2 
            nums.sort() 
            index =  len(nums)/2
    
            if len(nums)%2 == 0:
                return float(nums[index-1] + nums[index])/2
            else:
                return float(nums[len(nums)/2])
    

Log in to reply
 

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