# 可以形成最大正方形的矩形数目
import java.util.Arrays;
/**
* @author yagol
* @date 上午8:40
* @desc the description of this class
**/
class Solution1725 {
public static void main(String[] args) {
System.out.println(new Solution1725().countGoodRectangles(
new int[][]{{5, 8}, {9, 9}, {5, 12}, {16, 5}}
));
}
public int countGoodRectangles(int[][] rectangles) {
int maxlength = 0;
int count = 0;
for (int[] rectangle : rectangles) {
int x = rectangle[0];
int y = rectangle[1];
int min = Math.min(x, y);
if (min > maxlength) {
maxlength = min;
count = 1;
} else {
if (min == maxlength) {
count++;
}
}
}
return count;
}
}
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
31
32
33
34
35
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
31
32
33
34
35