题目有问题
The definition of the index is that a scholar with an index of h has published h papers each of which has been cited in other papers at least h times.
class Solution {
public:
int hIndex(vector<int>& citations) {
sort(citations.rbegin(),citations.rend());
for(int i=0;i<citations.size();++i)
if(citations[i]<=i) return i;
return citations.size();
}
};
本文介绍了一种计算学者H指数的方法,通过将引用次数降序排列并遍历比较,找到满足条件的最大H值。该算法首先对引用次数进行降序排序,然后从高到低检查每个引用数是否小于等于其索引值,以此确定H指数。

1128

被折叠的 条评论
为什么被折叠?



