598. 区间加法 II

Problem:

598. 区间加法 II

思路

脑筋急转弯:因为左上角的矩阵一直在累加,所以统计最小的行和列即可

Code

class Solution {
    public int maxCount(int m, int n, int[][] ops) {
        int r = m;
        int l = n;
        for (int i = 0; i < ops.length; i++) {
            // System.out.println(ops[i][0] + "," + ops[i][1] + "," + r + "," + l);
            r = Math.min(r, ops[i][0]);
            l = Math.min(l, ops[i][1]);
            // System.out.println(ops[i][0] + "," + ops[i][1] + "," + r + "," + l);
        }

        return r * l;
    } 
}
posted @ 2025-02-02 23:15  韩熙隐ario  阅读(14)  评论(0)    收藏  举报