Find rectangle with corners as 1
Medium Accuracy: 70.94% Submissions: 241 Points: 4

Given a NxM binary matrix consisting of 0s and 1s. Find if there exists a rectangle/ square within the matrix whose all four corners are 1. 

Example 1:

Input:
N = 4, M = 5
matrix[][] = 
{{1 0 0 1 0},
{0 0 1 0 1},
{0 0 0 1 0}, 
{1 0 1 0 1}} 

Output: Yes
Explanation:
Valid corners are at index (1,2), (1,4), (3,2), (3,4) 

Example 2:

Input:
N = 3, M = 3
matrix[][] = 
{{0 0 0},
{0 0 0},
{0 0 0}}
Output: No

Your Task:
You don't need to take input or print anything. Complete the function ValidCorners() that takes the given matrix as input parameter and returns a boolean value.

Constraints:
1 <= R, C <= 200
0 <= A[i] <= 1

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Find rectangle with corners as 1

Output Window