본문 바로가기
Problem Solving/LeetCode

[LeetCode] 598. Range Addition II - Java

by graycode 2026. 9. 9.

• 문제 링크

 

Range Addition II - LeetCode

Can you solve this real interview question? Range Addition II - You are given an m x n matrix M initialized with all 0's and an array of operations ops, where ops[i] = [ai, bi] means M[x][y] should be incremented by one for all 0 <= x < ai and 0 <= y < bi.

leetcode.com

 

• 풀이 코드

public class Solution {

    public int maxCount(int m, int n, int[][] ops) {
        for (int[] op : ops) {
            m = Math.min(m, op[0]);
            n = Math.min(n, op[1]);
        }

        return m * n;
    }

}

댓글