Posts

Showing posts from April 22, 2021

Largest Submatrix - 1s Diagonal

Image
 Largest Submatrix - 1s Diagonal  PROBLEM STATEMENT : The program must accept an integer matrix of size R*C containing only 0s and 1s as the input. The program must print the largest square submatrix where all the elements in the top-left to bottom-right diagonal are equal to 1. If two or more such largest square matrices occur, then the program must print the first occurring largest square submatrix as the output. If there is no such square submatrix, then the program must print -1 as the output.  Boundary Condition(s):  2 <= R, C <= 50  Input Format:  The first line contains R and C separated by a space.  The next R lines, each contains C integers separated by a space.  Output Format:  The lines containing the largest square submatrix where all the elements in the top-left to bottom-right diagonal are equal to 1  Example Input/Output 1: Input: ( ) 10 10 1 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 ...