Question
In c++ given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall
In c++ given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
The overall run time complexity should be O(log (m+n)).
Input
In the first line enter the size of the first array
In the second line enter the list of numbers of the first array
In the third line enter the size of the second array
In the last line enter the list of numbers of the second array
Output
The output is the median of the two sorted arrays
Example of input
2 1 3 1 2
Example of output
The median is 2
Constraints:
nums1.length == m
nums2.length == n
0 <= m <= 1000
0 <= n <= 1000
1 <= m + n <= 2000
-106 <= nums1[i], nums2[i] <= 106
GIVEN CODE TO WORK WITH:
#include
using namespace std;
double findMedianSortedArrays(vector
int main(){ vector
//Enter size of vector 1: cin>>sizeFirstList; if(sizeFirstList<0 || sizefirstlist>1000) { cout<<"Try again and enter an integer greater than or equal to 0, and less than or equal to 1000"< //Enter size of vector 2: cin>>sizeSecondList; if(sizeSecondList<0 || sizesecondlist>1000) { cout<<"Try again and enter an integer greater than or equal to 0, and less than or equal to 1000"< cout<<"The median is "<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started