• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
July 04, 2022 |1.1K Views

Find if there is a rectangle in binary matrix with corners as 1

Description
Discussion

There is a given binary matrix, we need to find if there exists any rectangle or square in the given matrix whose all four corners are equal to

Examples:

Input :
mat[][] = { 1 0 0 1 0
           0 0 1 0 1
           0 0 0 1 0
           1 0 1 0 1}
Output : Yes
as there exists-
1 0 1
0 1 0
1 0 1

We start scanning the matrix whenever we find a 1 at any index then we try for all the combinations for index with which we can form the rectangle.

 

Find if there is a rectangle in binary matrix with corners as 1 : https://www.geeksforgeeks.org/find-rectangle-binary-matrix-corners-1/