python code


  • 0
    T

    class Solution(object):
    def findMedianSortedArrays(self, nums1, nums2):

        """
        :type nums1: List[int]
        :type nums2: List[int]
        :rtype: float
        """
        num = nums1 + nums2
        num_new=sorted(num)
        length=len(num_new)
        mid=(length-1)/2
        #print mid
        if length%2==0:
            #mid=(len(num_new))/2
            print num_new[mid], num_new[mid+1]
            x=(float(num_new[mid])+float(num_new[mid+1]))/2
            return x
        else:
            x=divmod(length,2)
            y=x[0]
            
            return num_new[y]

Log in to reply
 

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