Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e825772

Browse files
authored
Create Day-30_Range_Addition_II.py
1 parent 7dbb709 commit e825772

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#########
2+
# The maximum value is present in between [0, min(a)] and [0, min(b)]. So return min(a) * min(b) for all the items in "ops" list.
3+
# Special Case: When ops is empty, then the answer is 0 and the number of 0's is nothing but m * n
4+
#########
5+
6+
class Solution:
7+
def maxCount(self, m: int, n: int, ops: List[List[int]]) -> int:
8+
# Case when ops = []
9+
if not ops:
10+
return m * n
11+
min_a, min_b = float('inf'),float('inf')
12+
for i in ops:
13+
min_a = min(i[0], min_a)
14+
min_b = min(i[1], min_b)
15+
16+
return min_a * min_b

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /