class Solution(object):
def findMedianSortedArrays(self, nums1, nums2):
"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: float
"""
nums1.extend(nums2)
a=sorted(nums1)
if len(a)%2==0 :
r=float(float(a[len(a)/21]+a[len(a)/2])/2.0)
else:r=a[len(a)/2]
return r
Why this simple python code is accepted and only 124ms?


@joshuia Because the nums1 and nums2 are already sorted. Python's default sort function is Tim sort, which has great performance in this case.

