#302·interview

MedianOfTwoSortedArrayOfDifferentLength.java

Author: kavi-senewiratneCreated Nov 3, 2020Updated Nov 9, 2020

Could someone tell me why input2 has to be longer in length than input1?

I did some examples by hand and this is definitely right, but I am failing to understand the logic behind it. Is it because when input2 is longer, there is more flexibility in moving the partitions around?

if (input1.length > input2.length) { return findMedianSortedArrays(input2, input1); }