Question bank › Matrix
Dsa Matrix Hard

Median of Rows

Given a 2D matrix of integers where each row is sorted in non-decreasing order, find the median of the complete matrix. The median is the middle element when the elements are sorted. If the number of elements is even, return the average of the two middle values. Input: - The first line contains two integers m (number of rows) and n (number of columns), - The next m lines each contain n integers representing the matrix. Output: - A float representing the median value. Example: Input: 3 3 1 3 5 2 6 8 0 9 10 Output: 5

Key concepts

matrixmediansorting

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.