akshitagit / CPP

Repository for C++/C codes and algos.
https://github.com/akshitagupta15june
MIT License
495 stars 434 forks source link

Median of two Sorted Arrays #158

Open pranjalibajpai opened 4 years ago

pranjalibajpai commented 4 years ago

Given two sorted arrays A and B of sizes n, m respectively. Find the median of these two arrays in O(1) space i.e. find the median without actually merging the two arrays.

Input Format First line contains two integers - n, m Next two lines contain n and m integers respectively.

Output Format Single integer denoting the median of the given arrays.

Sample Input
3
4
1 3 6 
2 4 8 10
Sample Output
4

Explanation
Array - 1 2 3 4 6 8 10
Median - 4
Sample Input
4
4
1 3 6 9 
2 4 8 10
Sample Output
5

Explanation
Array - 1 2 3 4 6 8 9 10
Median - (4+6)/2 = 5

Add code in the Interview Questions repo.

d2Anubis commented 4 years ago

I want to try this.

Maitryee-Choudhary commented 4 years ago

I would like to work on this.

hritikkhurana10sm commented 4 years ago

Can I work on this as a part of hacktober fest 2020. please assign .

kothawade29 commented 4 years ago

Hello @pranjalibajpai can you please assign this issue?

piyush9311 commented 4 years ago

may I work on this issue pls.