之前见过一道原题;
卡在了单调栈上的第二维度排序上;
具体代码: 1.单调栈:class Solution {
public:
int numberOfWeakCharacters(vector>& properties) {
int n=properties.size();
vectorarr;
sort(properties.begin(),properties.end(),[](vector& a,vector& b){
if(a[0]==b[0])
return a[1]>b[1];
else
return a[0]st;
int cnt=0;
for(int i=0;i
2.排序方法:
class Solution {
public:
int numberOfWeakCharacters(vector>& properties) {
int n=properties.size();
vectorarr;
sort(properties.begin(),properties.end(),[](vector& a,vector& b){
if(a[0]==b[0])
return a[1]b[0];
});
int maxdef=0;
int cnt=0;
for(int i=0;iproperties[i][1]){
cnt++;
}
maxdef=max(maxdef,properties[i][1]);
}
return cnt;
}
};



