Median of Array


#1

Wrong Answer. Your program’s output doesn’t match the expected output. You can try testing your code with custom input and try putting debug statements in your code.

Your submission failed for the following input:

A : [ -50, -41, -40, -19, 5, 21, 28 ]B : [ -50, -21, -10 ]

Your function returned the following :

-19.0

The expected returned value :

-20.0

Someone please explain this


#2

if you combine both array in sorted order it would become.
[-50, -50, -41, -40, -21, -19, -10, 5, 21, 28]

Now you are suppose to find Median for Even number of elements
So it would be, (n/2 + (n/2 +1))/2
n/2 = 5th element => -21
n/2 +1 = 6th elements => -19
(-21 + -19)/2 = -20