1-liner Python (beat 90%) and 2-liner C++ find min(a, m)*min(b, n)

  • 0

    Note that min(a) and min(b) represent the intersected area of all operated regions.

        int maxCount(int m, int n, vector<vector<int>>& ops) {
            for (auto& op : ops) m = min(m, op[0]), n = min(n, op[1]);
            return m*n;


        def maxCount(self, m, n, ops):
            return min(op[0] for op in ops)*min(op[1] for op in ops) 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.