C++ simple solution


  • 0
    S

    It is sufficient to track just the min a and min b

    class Solution {
    public:
        int maxCount(int m, int n, vector<vector<int>>& ops) {
            if (ops.empty()) return m*n;
            int mina = m+2;
            int minb = n+2;
            for (int i = 0; i < ops.size(); i++) {
                if (ops[i][0] < mina) {
                    mina = ops[i][0];
                }
                if (ops[i][1] < minb) {
                    minb = ops[i][1];
                }
            }
            return mina*minb;
        }
    };

Log in to reply
 

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