```
double findMedianSortedArrays(int A[], int m, int B[], int n) {
int C[m+n];
int im=0;
int in=0;
while(im<m && in < n){
if(A[im]<=B[in]){
im++;
C[im+in-1] = A[im-1];
}else{
in++;
C[im+in-1] = B[in-1];
}
}
if(im<m){
for(im;im<m;im++){
C[im+in] = A[im];
}
}else if(in < n){
for(in;in<n;in++){
C[im+in] = B[in];
}
}
if((m+n)%2==0)
return ((float)C[(m+n)/2] + C[(m+n-1)/2])/2;
else
return C[(m+n)/2];
}
```

worst case: O(m+n)

best case O(1)

but what is the overall complexity?