Login

Striver SDE Sheet Problems

Problem title

Difficulty

Avg time to solve

Kth largest element in the unsorted array

Moderate

10 mins

Triplets with Given Sum

Moderate

15 mins

Majority Element - II

Easy

10 mins

Maximum Consecutive Ones

Moderate

30 mins

Stocks are profitable

Moderate

20 mins

Matrix Median

Moderate

15 mins

Clone Linked List with Random Pointer

Easy

10 mins

Missing and repeating numbers

Moderate

25 mins

Minimum Characters For Palindrome

Hard

20 mins

Majority element

Easy

15 mins

Problem

Submissions

13

Avg. time to solve

15 min

Success Rate

90%

Problem Statement

```
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain two integers ‘N’ and ‘M’ denoting the number of rows and columns, respectively.
Next ‘N’ lines contain ‘M’ space-separated integers each denoting the elements in the matrix.
```

```
For each test case, print an integer which is the overall median of the given matrix.
Output for every test case will be printed in a separate line.
```

```
You don’t need to print anything; It has already been taken care of. Just implement the given function.
```

```
1 <= 'T' <= 50
1 <= 'N' , 'M' <= 100
1 <= 'MATRIX'['I']['J'] <= 10 ^ 5
'N' * 'M' is always an odd number.
Where 'MATRIX'['I']['J'] denotes the value at ('I', 'J')th cell in the matrix.
Time limit: 1 sec
```

```
2
1 3
1 2 3
3 3
2 6 9
1 5 11
3 7 8
```

```
2
6
```

```
In the first test case, the overall median of the matrix is 2.
In the second test case, the overall median of the matrix is 6.
```

```
2
3 3
2 6 8
1 4 7
6 8 9
3 5
1 2 6 6 10
2 4 4 5 7
2 5 5 6 6
```

```
2
5
```

```
In the first test case, the overall median of the matrix is 2.
In the second test case, the overall median of the matrix is 5.
```

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Language

Change Theme

Solution submission not allowed

Save Code

Reset Code