File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 462
462
592|[ Fraction Addition and Subtraction] ( ./0592-fraction-addition-and-subtraction.js ) |Medium|
463
463
593|[ Valid Square] ( ./0593-valid-square.js ) |Medium|
464
464
594|[ Longest Harmonious Subsequence] ( ./0594-longest-harmonious-subsequence.js ) |Easy|
465
+ 598|[ Range Addition II] ( ./0598-range-addition-ii.js ) |Easy|
465
466
599|[ Minimum Index Sum of Two Lists] ( ./0599-minimum-index-sum-of-two-lists.js ) |Easy|
466
467
605|[ Can Place Flowers] ( ./0605-can-place-flowers.js ) |Easy|
467
468
606|[ Construct String from Binary Tree] ( ./0606-construct-string-from-binary-tree.js ) |Easy|
Original file line number Diff line number Diff line change
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
+ } ;
You can’t perform that action at this time.
0 commit comments