Median in a 2 d array

im very confused with question please help me by explaining the solution(code) step by step.

i dont know how to approach this problem

please resolve my doubt because i have asked this doubt 15 min ago(approx).

Hey @prashantrsj25
Sorry for late reply
Having issues with laptop

So approach is

Say k = N*M/2. We need to find (k + 1)^th smallest element.
We can use binary search on answer. In O(N log M), we can count how many elements are smaller than X in the matrix.

So, we use binary search on interval [1, INT_MAX]. So, total complexity is O(30 * N log M).