C++ 3 lines

  • -1

    the left top corner always get incremented
    so the solution is the overlapped area for all input ops

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

Log in to reply

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