func findMedianSortedArrays(nums1 []int, nums2 []int) float64 {
var i, j, k int
var m = len(nums1)
var n = len(nums2)
var nums = make([]int, m+n)
for i!=m && j!=n{
if nums1[i]<nums2[j]{
nums[k] = nums1[i]
i++
}else{
nums[k] = nums2[j]
j++
}
k++
}
for i!=m{
nums[k] = nums1[i]
i++
k++
}
for j!=n{
nums[k] = nums2[j]
j++
k++
}
var mid int = int((m+n)/2)
if (m+n)%2==0{
return float64(nums[mid]+nums[mid-1])/2
}
return float64(nums[mid])
}
原文:https://www.cnblogs.com/pangqianjin/p/14657455.html