Median of a Matrix with sorted rows
I am not able to solve the following problem optimally nor finding an approach to do this anywhere. Given a N × M matrix in which each row is sorted, find the overall median of the matrix. Assume N*M is odd. For example, Matrix = [1, 3, 5] [2, 6, 9] [3, 6, 9] A = [1, 2, 3, 3, 5, 6, 6, 9, 9] Median is 5. So, we return 5. Note: No extra memory is allowed. Any help will be appreciated. sunkuet02 Consider the following process. If we consider the N*M matrix as 1-D array then the median is the element of 1+N*M/2 th element. Then consider x will be the median if x is an element of the matrix and