Skip to content

Instantly share code, notes, and snippets.

@amarjitdhillon
Created February 12, 2022 08:07
Show Gist options
  • Save amarjitdhillon/783bf3335248e5641832aea1506fbcd8 to your computer and use it in GitHub Desktop.
Save amarjitdhillon/783bf3335248e5641832aea1506fbcd8 to your computer and use it in GitHub Desktop.
Range Addition II
class Solution:
def maxCount(self, m: int, n: int, ops: List[List[int]]) -> int:
for r,c in ops:
# expand and shrink the matrix size (bottom-right boundry of matrix) based on the current operation
m = min(m,r)
n = min(c,n)
# total number of elements will be multiplication of bottom and right boundry asssming left and top boundry is 0,0
return m*n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment