Challenge 4: Find the Median of Two Sorted Arrays

Let's write a function to find the median of two sorted arrays

Problem Statement

Implement a function that takes two sorted arrays of variable length and finds the median of the two arrays.

Input

Two sorted arrays and their sizes

Output

The median of the two arrays

Sample Input

A = {100};
B = {1, 5, 8, 10, 20}

Sample Output

9

Coding Exercise

Take a close look and design a step-by-step algorithm before jumping on to implementation. This problem is designed for your practice, so try to solve it on your own first. If you get stuck, you can always refer to the hint and solution provided in the code tab. Good Luck!

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.