Median Sorted Arrays
Median of Two Sorted Arrays
project_name = "median_sorted_arrays" # give it an appropriate name
!pip install jovian --upgrade --quiet
WARNING: You are using pip version 20.3.3; however, version 21.0.1 is available. You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
The basic idea of this problem to find a median of two arrays. A median is an element that happens to lay in the middle of a sorted list of elements.
It's easy to find a median when the number of elements in said list is odd, since there is only one element that lays in the middle (at position n/2). If the number of elements is even, then there's more than one middle element. In such case we consider median to be an average of elements at positions n/2-1 and n/2.