Skip to content

Commit d19f8da

Browse files
solves range addition II
1 parent e44cd75 commit d19f8da

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
| 589 | [N-Ary Tree Preorder Traversal](https://leetcode.com/problems/n-ary-tree-preorder-traversal) | Easy | [![Java](assets/java.png)](src/NArayTreePreOrderTraversal.java) [![Python](assets/python.png)](python/n_ary_tree_preorder_traversal.py) |
157157
| 590 | [N-Ary Tree Postorder Traversal](https://leetcode.com/problems/n-ary-tree-postorder-traversal) | Easy | [![Java](assets/java.png)](src/NAryTreePostorderTraversal.java) [![Python](assets/python.png)](python/n_ary_tree_postorder_traversal.py) |
158158
| 594 | [Longest Harmonious Subsequence](https://leetcode.com/problems/longest-harmonious-subsequence) | Easy | [![Java](assets/java.png)](src/LongestHarmoniousSubsequence.java) [![Python](assets/python.png)](python/longest_harmonious_subequence.py) |
159-
| 598 | [Range Addition II](https://leetcode.com/problems/range-addition-ii) | Easy | |
159+
| 598 | [Range Addition II](https://leetcode.com/problems/range-addition-ii) | Easy | [![Java](assets/java.png)](src/RangeAdditionII.java) [![Python](assets/python.png)](python/range_addition_ii.py) |
160160
| 599 | [Minimum Index Sum of 2 Lists](https://leetcode.com/problems/minimum-index-sum-of-two-lists) | Easy | |
161161
| 604 | [Design Compressed String Iterator](https://leetcode.com/problems/design-compressed-string-iterator) | Easy | |
162162
| 605 | [Can Place Flowers](https://leetcode.com/problems/can-place-flowers) | Easy | |

python/range_addition_ii.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def maxCount(self, m: int, n: int, ops: List[List[int]]) -> int:
6+
for operation in ops:
7+
m = min(m, operation[0])
8+
n = min(n, operation[0])
9+
return m * n

src/RangeAdditionII.java

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class RangeAdditionII {
2+
public int maxCount(int m, int n, int[][] operations) {
3+
for (int[] operation : operations) {
4+
m = Math.min(m, operation[0]);
5+
n = Math.min(n, operation[1]);
6+
}
7+
return m * n;
8+
}
9+
}

0 commit comments

Comments
 (0)