魔法师 (@Constanline)Leetcode每日一题 —— 3531. 统计被覆盖的建筑 中发帖

3531. 统计被覆盖的建筑 
思路
看数据量n^2肯定是要超时的。不过题目只需要上下左右方向上有一个而不是上下左右有一个,所以只要找到每行的最左最右和每列的最上最下,然后遍历一遍确定是否在范围内即可。
代码
public int countCoveredBuildings(int n, int[][] buildings) {
int ans = 0;
int[] left = new int[n + 1];
int[] right = new int[n + 1];
int[] top = new int[n + 1];
int[] bottom = new int[n + 1];
Arrays.fill(left, Integer.MAX_VALUE);
Ar...