[LeetCode] 4. Median of Two Sorted Arrays
Python
class Solution:
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
nums = nums1 + nums2
nums.sort()
if len(nums) % 2 == 0:
return (nums[len(nums) // 2] + nums[len(nums) // 2 - 1]) / 2
else:
return nums[len(nums) // 2]
댓글남기기