12/13
复杂度(n+m)
class Solution {
public double findMedianSortedArrays(int[] nums1, int[] nums2) {
int n1=nums1.length;
int n2=nums2.length;
if(n1+n2==0){
return 0;
}
int st1=0;
int st2=0;
int st=0;
int[] nums=new int[n1+n2];
while(st!=n1+n2){
if(st1==n1){
nums[st++]=nums2[st2++];
}else if(st2==n2){
nums[st++]=nums1[st1++];
}else if(nums1[st1]<=nums2[st2]){
nums[st++]=nums1[st1++];
}else{
nums[st++]=nums2[st2++];
}
}
if((n1+n2)%2==0){
return (nums[(n1+n2-1)/2]+nums[(n1+n2)/2])/2.0;
}else{
return nums[(n1+n2)/2];
}
}
}
复杂度log(m+n0的做法晚点补