Skip to content

Commit 72c3ec8

Browse files
committed
Add solution #598
1 parent 7af3058 commit 72c3ec8

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@
462462
592|[Fraction Addition and Subtraction](./0592-fraction-addition-and-subtraction.js)|Medium|
463463
593|[Valid Square](./0593-valid-square.js)|Medium|
464464
594|[Longest Harmonious Subsequence](./0594-longest-harmonious-subsequence.js)|Easy|
465+
598|[Range Addition II](./0598-range-addition-ii.js)|Easy|
465466
599|[Minimum Index Sum of Two Lists](./0599-minimum-index-sum-of-two-lists.js)|Easy|
466467
605|[Can Place Flowers](./0605-can-place-flowers.js)|Easy|
467468
606|[Construct String from Binary Tree](./0606-construct-string-from-binary-tree.js)|Easy|

solutions/0598-range-addition-ii.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* 598. Range Addition II
3+
* https://leetcode.com/problems/range-addition-ii/
4+
* Difficulty: Easy
5+
*
6+
* You are given an m x n matrix M initialized with all 0's and an array of operations ops,
7+
* where ops[i] = [ai, bi] means M[x][y] should be incremented by one for all 0 <= x < ai
8+
* and 0 <= y < bi.
9+
*
10+
* Count and return the number of maximum integers in the matrix after performing all the
11+
* operations.
12+
*/
13+
14+
/**
15+
* @param {number} m
16+
* @param {number} n
17+
* @param {number[][]} ops
18+
* @return {number}
19+
*/
20+
var maxCount = function(m, n, ops) {
21+
let a = m;
22+
let b = n;
23+
24+
for (const op of ops) {
25+
a = Math.min(a, op[0]);
26+
b = Math.min(b, op[1]);
27+
}
28+
29+
return a * b;
30+
};

0 commit comments

Comments
 (0)