说实话题没怎么看懂
暴力解…
class Solution {
public:
int hIndex(vector<int>& citations) {
int n = citations.size();
map<int, int> mp;
for (int h = 1; h <= n; h++) {
//至少发表了 h 篇论文
for (auto& x : citations) {
//论文被引用次数 x 大于等于 h
if (x >= h) {
mp[h] += 1;//mp[h]表示论文被引用次数大于h的论文数量
}
}
}
int res = 0;
for (auto& x : mp) {
// 至少有 h 篇论文(mp[h]) 被引用次数大于等于 h
if (x.second >= x.first) {
res = max(res, x.first);
}
}
return res;
}
};