
解題思路:
解決本題的關鍵在于思維,既然是要求最大數的個數,那么就維護一個最大數的范圍區間,即所有范圍的交集,最后回傳范圍乘積即可,代碼如下:
class Solution {
public:
int maxCount(int m, int n, vector<vector<int>>& ops) {
int a = m, b = n;
for(auto& op : ops) {
a = min(a, op[0]);
b = min(b, op[1]);
}
return a * b;
}
};
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/352138.html
標籤:其他
