python-algorithm
Leetcode 4. Median of Two Sorted Arrays
무적김두칠
2021. 8. 19. 13:31
1
2
3
4
5
6
7
|
pythoclass Solution:
def findMedianSortedArrays(self, nums1: List[int], nums2: List[int]) -> float:
for i in nums2:nums1.append(i)
nums1.sort()
chk=len(nums1)
if chk%2==1 : return nums1[chk//2]
else: return (nums1[chk//2]+nums1[chk//2-1])/2
|
cs |
반응형