标签:highlight nbsp pre code fir vector max return turn
class Solution {
public:
int findLHS(vector<int>& nums) {
int res=0;
map<int,int> m;
for(auto num:nums) ++m[num];
for(auto a:m){
if (m.count(a.first+1)){
res=max(res,m[a.first]+m[a.first+1]);
}
}
return res;
}
};
标签:highlight nbsp pre code fir vector max return turn
原文地址:https://www.cnblogs.com/learning-c/p/9735430.html