classSolution{public:doublefindMedianSortedArrays(vector<int>& nums1, vector<int>& nums2){int m = nums1.size();int n = nums2.size();int i =0, j =0;int k =(m+n)/2, t =0, res=0, pre=0;while(t <= k && i < m && j < n){if(nums1[i]< nums2[j]){
pre = res;
res = nums1[i++];}else{
pre = res;
res = nums2[j++];}
t++;}while(i == m && t <= k){
pre = res;
res = nums2[j++];
t++;}while(j == n && t <= k){
pre = res;
res = nums1[i++];
t++;}if((m+n)%2)return res;return(res+pre)/2.0;}};