Skip to content

Instantly share code, notes, and snippets.

@kartikkukreja
Last active October 13, 2016 05:01
Show Gist options
  • Save kartikkukreja/596d7ad51c315629adf8a5e2c91ceeaa to your computer and use it in GitHub Desktop.
Save kartikkukreja/596d7ad51c315629adf8a5e2c91ceeaa to your computer and use it in GitHub Desktop.
median of two sorted arrays example
Input:
A = [1,3,5]
B = [4,7]
Output:
4
Explanation:
The combined array is [1,3,4,5,7] and the middle element is 4.
Input:
A = [1,3,4,5]
B = [2,7]
Output:
3.5
Explanation:
The combined array is [1,2,3,4,5,7].
The two middle elements are 3 and 4 and their average is 3.5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment