My 5 liner in python for Median of Two Sorted Arrays

  • -1

    Beats 98% of python code in speed

    class Solution(object):

    def findMedianSortedArrays(self, nums1, nums2):
        num = sorted(nums1 + nums2)
        n = len(num)/2
        m = (num[n-1]+num[n])/2.0  if len(num)%2==0  else num[n]
        return m

Log in to reply

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