Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Last Updated: 11 Nov, 2020

Largest Rectangle in Matrix

Moderate
Asked in company
Publicis Sapient

Problem statement

You are given a 2D matrix of size N x M consisting of only 0s and 1s. You need to find the biggest rectangle in that matrix that consists of only 1s

Input format:
The first line consists of two space-separated integers, N and M representing the rows and columns of the matrix
The next N lines consist of M space-separated integers representing the elements of the matrix
Output format:
Size of the largest rectangle
Constraints:
0 <= N <= 1000
0 <= M <= 1000