Given a binary matrix of integers **A** of size **N x M** consisting of only **0** or **1**.

you need to check whether there exists a square or rectangle in a square whose all four corners are **1**.

All four corners need to be distinct.

If there exists such rectangle or square return 1, else return 0.

**Input Format**

```
The first argument given is the integer matrix A.
```

**Output Format**

```
Return 1 if there exists such rectangle/square whose all four corners are 1 else return 0.
```

**Constraints**

```
1 <= N, M <= 200
0 <= A[i] <= 1
```

**For Example**

```
Input 1:
A = [ [0, 1, 1]
[0, 1, 1]
[0, 1, 0] ]
Output 1:
1
Explanation 1:
[ [1, 1]
[1, 1] ]
There exists a square whose all corners are 1.
Input 2:
A = [ [0, 1, 1]
[0, 0, 1]
[0, 1, 0] ]
Output 2:
0
```

NOTE:You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.

Sign Up

to access hints and editorial solutions for**Find Rectangle in binary matrix**

to access hints and editorial solutions for

Loading...