1 line methods in python


  • 0
    F

    method 1:

        def maxCount1(self, m, n, ops):
            """
            :type m: int
            :type n: int
            :type ops: List[List[int]]
            :rtype: int
            """
            from operator import mul
            return mul(*map(min, zip(*ops))) if ops else m * n
    

    method 2, I want to use numpy, but the server cannot work well, but works well on my own machine:

        def maxCount2(self, m, n, ops):
            """
            :type m: int
            :type n: int
            :type ops: List[List[int]]
            :rtype: int
            """
            import numpy as np
            return np.prod(np.min(ops, axis=0)) if ops else m * n

Log in to reply
 

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