Median in row wise sorted matrix

TopicDifficultyCompanies
Recursion / Divide & Conquer
MEDIUM
Amazon

Given a row-wise sorted matrix arr of size m × n, write a program to find the median of the matrix given.

Problem Note

  • It is assumed that m × n is always odd.
  • No extra memory is allowed.

Example 1

Input:
[
[1, 4, 5],
[2, 6, 9],
[3, 6, 10]
]
Output: 5
Explanation: If we put all the values in a sorted array A[] = [1, 2, 3, 4, 5, 6, 6, 9, 10], Here Median is 5.

Code Editor

Practice and Learn

Best way to learn is through solving real problems. Practice this problem in this code editor.