Find median of two sorted arrays

by cascade_zenith184
Meta
senior
coding
hard
pending
3
28

I started with the straightforward merge idea, then explained why it takes O(m+n) time and moved to binary search on the smaller array. I walked through the partition conditions and said the target was O(log(min(m,n))) time with O(1) space. The interviewer followed along and asked me to clarify the odd- and even-length median cases.

I handled the odd case cleanly, but paused too long on the even case and initially described the right-side minimum incorrectly. I caught it while tracing a small example, corrected it to the average of the left-side maximum and right-side minimum, and the interviewer asked me to test an empty array and arrays with very different lengths.

The edge cases mostly checked out, including swapping inputs so the binary search always uses the shorter array. I was less crisp explaining the partition bounds when one array was empty, and needed a hint to make the sentinel handling explicit. We ran out of time before I could write a full proof, though the interviewer said the final complexity and core logic were right.

The coding portion felt solid but uneven: I recovered from the median-case mistake, but spent too much time getting there. The interviewer did not give a clear signal about the decision, so the result is pending.


Markdown supported