GEEK01 - Editorial

Problem Link

Practice

Contest

Author: Bhuvnesh Jain

Tester: Bhuvnesh Jain

Editorialist: Bhuvnesh Jain

Difficulty

CAKEWALK

Prerequisites

Sorting, Looping Techniques

Problem

The median of a matrix is defined as the median of the median of all rows. Find the median of the matrix.

Explanation

To find the median, we need the numbers to be sorted in increasing order. To sort the numbers, we can use merge sort or inbuilt sort algorithm available in the languages. Once, we find the median of all rows, we can do the same trick to find the median of all rows.

To read more about sorting algorithms, refer to this link

Time Complexity

O(N * N * \log{N}), per test case.

Space Complexity

O(N * N)

Solution Links

Setter’s solution