Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Created September 17, 2019 23:02
Show Gist options
  • Save DataSolveProblems/375f7a91d92af6de1c70e1efa02e5913 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/375f7a91d92af6de1c70e1efa02e5913 to your computer and use it in GitHub Desktop.
class Solution:
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
nums1.extend(nums2)
nums1 = sorted(nums1)
if len(nums1) % 2 == 0:
n = len(nums1) // 2
return (nums1[n - 1] + nums1[n]) / 2
else:
n = (len(nums1) // 2) + 1
return nums1[n - 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment