forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_750.java
30 lines (29 loc) · 1.02 KB
/
_750.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package com.fishercoder.solutions;
public class _750 {
public static class Solution1 {
public int countCornerRectangles(int[][] grid) {
if (grid == null || grid.length < 2) {
return 0;
}
int m = grid.length;
int n = grid[0].length;
int count = 0;
for (int i = 0; i < m - 1; i++) {
for (int j = 0; j < n - 1; j++) {
if (grid[i][j] == 1) {
for (int jNext = j + 1; jNext < n; jNext++) {
if (grid[i][jNext] == 1) {
for (int iNext = i + 1; iNext < m; iNext++) {
if (grid[iNext][j] == 1 && grid[iNext][jNext] == 1) {
count++;
}
}
}
}
}
}
}
return count;
}
}
}