30,416
社区成员




原题链接:1996. 游戏中弱角色的数量
来源:「力扣官方题解」
class Solution {
public:
typedef pair<int,int> pii;
static bool cmp(const vector<int>&a, const vector<int>& b) {
if(a[0] == b[0]) return a[1] < b[1];
return a[0] > b[0];
}
int numberOfWeakCharacters(vector<vector<int>>& properties) {
sort(properties.begin(), properties.end(),cmp);
int res = 0;
int Max = 0;
for(auto p : properties) {
if(p[1] < Max) res++;
else Max = p[1];
}
return res;
}
};