

'm' and 'n' will always be odd.
Input: 'n' = 5, 'm' = 5
'mat' =
[ [ 1, 5, 7, 9, 11 ],
[ 2, 3, 4, 8, 9 ],
[ 4, 11, 14, 19, 20 ],
[ 6, 10, 22, 99, 100 ],
[ 7, 15, 17, 24, 28 ] ]
Output: 10
Explanation: If we arrange the elements of the matrix in the sorted order in an array, they will be like this-
1 2 3 4 4 5 6 7 7 8 9 9 10 11 11 14 15 17 19 20 22 24 28 99 100
So the median is 10, which is at index 12, which is midway as the total elements are 25, so the 12th index is exactly midway. Therefore, the answer will be 10.
The first line contains two space-separated integers, 'm', and 'n', representing the number of rows and the columns of the matrix, respectively.
Each of the next 'm' lines contains 'n' space-separated integers denoting the elements of the matrix.
Return a single integer representing the median of the matrix.
You don’t have to print anything; it has already been taken care of. Just implement the given function.
The idea is that we would spread out the whole matrix and store it in an array and after that we would sort that array and check the middle of the array.
The idea is that, for a number to be the median of the matrix the number should be exactly greater than half the numbers in the matrix. Therefore, we will find the count of numbers less than each number, and the element which satisfies the above property will be the median.
Sorted Doubly Linked List to Balanced BST
Largest Plus Sign
Minimum Operations to Form Letter Y
Matrix Block Sum
Minimized Maximum of Products Distributed to Any Store