【leetCode】H-Index

本文介绍了H-Index的概念,它是衡量科研人员学术成就的指标。给定一个整数数组citations,表示论文的引用次数,任务是计算其H-Index。通过将citations数组降序排列,然后遍历找到满足H-Index条件的元素个数,实现算法。示例中,输入[3, 0, 6, 1, 5],H-Index为3。提供的C++代码实现能完成此计算。" 78384647,7361956,PAT乙级1017. A除以B模拟算法解析,"['算法', '编程竞赛', 'PAT乙级题解', '数学运算', '字符串操作']
摘要由CSDN通过智能技术生成

Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.

According to the definition of h-index on Wikipedia: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each."

For example, given citations = [3, 0, 6, 1, 5], which means the researcher has 5 papers in total and each of them had received 3, 0, 6, 1, 5 citations respectively. Since the researcher has 3 papers with at least 3 citations each and the remaining two with no more than 3 citations each, his h-index is 3.

Note: If there are several possible values for h, the maximum one is taken as the h-index.


中文:

H-Index是衡量一个人学术水平的指数。接下来我们简称h。

h代表“高引用次数”(high citations),一名科研人员的h指数是指他至多有h篇论文分别被引用了至少h次。h指数能够比较准确地反映一个人的学术成就。一个人的h指数越高,则表明他的论文影响力越大。例如,某人的h指数是20,这表示他已发表的论文中,每篇被引用了至少20次的论文总共有20篇。------By 百度百科。

传入一个citations的Vector,每一个元素代表每一篇论文的被引用次数。求出这个citations的H-index。比如[3, 0, 6, 1, 5]中对于下标0的论文,值为3,那么要求至少有3篇论文的引用数要大于等于3。检查有下标为3,5,6;共计三篇论文的引用次数超过了。H-Index = 3。如是依次检查剩下的元素。


我的思路:

先对Vector从低到高排序。那么根据H-index的定义我们只要找到这个一个元素i。算上i,到Vector末尾,这区间中的元素数量要大于等于i的值。

编辑器不知道怎么始终贴不上代码片段。只好直接粘贴了。

class Solution {
public:
int hIndex(vector<int>& citations) {
sort(citations.begin(), citations.end(),std::less<int>());
int length = citations.size();
int hIndex = 0;
for (int i = 0; i < length; i++)
{
int temp = 0;
//他已发表的论文中,每篇被引用了至少20次的论文总共有20篇->某人的h指数是20
if (length - i <= citations[i])
{
hIndex = length-i;
break;
}
}
return hIndex;
}
};


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值