Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

You are given an 'N' * 'M' size binary-valued matrix, where 'N' is the number of rows and 'M' is the number of columns.

Your task is to return the size (area) of the maximum size submatrix which consists of all 1s i.e. the maximum area of a submatrix in which each cell has only the value ‘1’.

```
1. Binary-valued matrix has either 0 or 1 in each cell.
2. A submatrix is a matrix formed by selecting certain rows and columns from a larger matrix.
```

```
In the above image, areas in green, red, and violet colour are all submatrices of the original 4x4 matrix.
3. The area of a matrix with 'H' rows and 'W' columns is equal to 'H' * 'W'.
```

Detailed explanation

```
1 <= T <= 50
1 <= N, M <= 100
Time Limit: 1 sec
```

```
1
5 4
1 0 1 1
1 0 1 1
0 1 0 1
1 1 1 1
0 0 0 1
```

```
5
```

```
1
4 4
1 1 1 1
1 1 1 1
0 0 1 1
0 0 1 1
```

```
8
```