Created
September 17, 2019 23:02
-
-
Save DataSolveProblems/375f7a91d92af6de1c70e1efa02e5913 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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