Write python code to find the submatrix. Thank you in Advance. You are given a 2D matrix that is filled with 1's in almost all the cells. However, there may be at most one rectangular submatrix that is filled with 0s. Implement an algorithm to return the size of the submatrix, in terms of width and height.
Write python code to find the submatrix.
Thank you in Advance.
You are given a 2D matrix that is filled with 1's in almost all the cells. However, there may be at most one rectangular submatrix that is filled with 0s. Implement an
Examples:
Input:
[[1,1,1,1,1,1,1],
[1,1,1,1,1,1],
[1,1,0,0,0,1],
[1,1,0,0,0,1],
11,1,1,1,1,1]]
Output: [3,2] (Because the width of the sumbmarix 3, and highets 2
Input:
[[1,1,1,1],
[1,1,1,1],
[1,1,1,1]]
Output: [0,0] (Because the there is no submatrix that contains 0s)
Input:
[[1,1,1,1],
[1,1,0,1]
[1,1,1,1]]
Output: [1,1] (Because the width of the submatrix of 0s is 1, and height is 1)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images