• 문제 링크
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;
}
}'Problem Solving > LeetCode' 카테고리의 다른 글
| [LeetCode] 605. Can Place Flowers - Java (0) | 2026.09.11 |
|---|---|
| [LeetCode] 599. Minimum Index Sum of Two Lists - Java (0) | 2026.09.10 |
| [LeetCode] 594. Longest Harmonious Subsequence - Java (0) | 2026.09.08 |
| [LeetCode] 590. N-ary Tree Postorder Traversal - Java (0) | 2026.09.07 |
| [LeetCode] 589. N-ary Tree Preorder Traversal - Java (0) | 2026.09.06 |
댓글