<p>Given two sorted arrays <code>nums1</code> and <code>nums2</code> of size <code>m</code> and <code>n</code> respectively, return <strong>the median</strong> of the two sorted arrays.</p>

<p>The overall run time complexity should be <code>O(log (m+n))</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums1 = [1,3], nums2 = [2]
<strong>Output:</strong> 2.00000
<strong>Explanation:</strong> merged array = [1,2,3] and median is 2.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums1 = [1,2], nums2 = [3,4]
<strong>Output:</strong> 2.50000
<strong>Explanation:</strong> merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>nums1.length == m</code></li>
	<li><code>nums2.length == n</code></li>
	<li><code>0 &lt;= m &lt;= 1000</code></li>
	<li><code>0 &lt;= n &lt;= 1000</code></li>
	<li><code>1 &lt;= m + n &lt;= 2000</code></li>
	<li><code>-10<sup>6</sup> &lt;= nums1[i], nums2[i] &lt;= 10<sup>6</sup></code></li>
</ul>


bool Is_odd(int in)
{
    return in%2!=0;
}

bool Is_even(int in)
{
    return in%2==0;
}
using vec_it=vector<int>::iterator;

class Solution {
public:
    double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
        double retval=0;
        int d=0;
        
        if(nums1.size()==0)
        {
             if(Is_odd(nums2.size()))
       {
        retval=nums2[(nums2.size()/2)];
        
       }
       else
       {
        
        retval=(double)(((double)nums2[(nums2.size()/2)-1]+(double)nums2[(nums2.size()/2)])/2);
       }
        return retval;

        }
          if(nums2.size()==0)
        {
             if(Is_odd(nums1.size()))
       {
        retval=nums1[(nums1.size()/2)];
        
       }
       else
       {
        
        retval=(double)(((double)nums1[(nums1.size()/2)-1]+(double)nums1[(nums1.size()/2)])/2);
       }
        return retval;

        }

        
        for(int i=0;i<nums1.size()&&d<nums2.size();i++)
        {
            
            
            
                if(nums1[i]>=nums2[d])
                {
                std::vector<int>::iterator it(&nums1[i]);
               nums1.insert(it,nums2[d]);
               d++;
                }    
             
        }
           if(d!=nums2.size())
                {
                    std::vector<int>::iterator it2(&nums2[d]);
                    nums1.insert(nums1.end(),it2,nums2.end());
                }
        
        
        int medium=(nums1.size()/2);
       if(Is_odd(nums1.size()))
       {
        retval=nums1[medium];
        
       }
       else
       {
        
        retval=(double)(((double)nums1[medium-1]+(double)nums1[medium])/2);
       }
        return retval;
    }
};
96000