Python solution , beat 100%


  • 5
    V

    An operation [a,b] add by one for all 0 <= i < a and 0 <= j < b.
    So the number of maximum integers in the matrix after performing all the operations or the integers in matrix that get added by 1 by all operations are the integers that in 0 <=i<min_a and 0<=i<min_b or min_a * min_b

        def maxCount(self, m, n, ops):
            """
            :type m: int
            :type n: int
            :type ops: List[List[int]]
            :rtype: int
            """
            if not ops:
                return m*n
            return min(op[0] for op in ops)*min(op[1] for op in ops)

  • 0
    A
    This post is deleted!

  • 0
    A

    Very nice to use generator comprehension!


  • 0
    W

    More concise than using for and if. Thanks.


  • 0
    X
        if not ops or not ops[0]:
            return m * n
        return min(list(zip(*ops))[0]) * min(list(zip(*ops))[1])

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.