H指数是用来综合衡量学者发表论文的数量和质量的指标,
若某学者共发表N篇论文,H指数是指存在h 篇论文至少每篇有h 引用量,剩下的N-h篇中,每篇都不超过h引用量

计算H指数的方法:
1、排序法
思路:
先将数组排序,我们就可以知道对于某个应用数,有多少文献的引用数大于这个数。对于引用数citations[i],大于该引用数
文献的数量是citations.length - i , 而当前的H-Index则是Math.min(citations[i],citations.length - i ),我们将这个
当前的H指数和全局最大的H指数来比较,得到最大的H指数。

程序设计:

public class Solution {
public int hIndex(int[] citations){
//排序
Arrays.sort(citations);
int h = 0 ;
for (int i = 0; i < citations.length; i++){
//得到当前的H指数
int currH = Math.min(citations[i],citations.length - i);
if (currH > h){
h = currH;
}
}
return h;
}
}

  

2、二分查找法:
思路:
在升序的引用数 数组中,假设数组长为N,下标为i ,则N - i 就是引用次数大于等于下标为i的文献所对应的引用次数的文章数。如果该位置的引用数小于文章数,
则说明则是有效的H指数,如果一个数是H指数,那最大的H指数一定在他的后面(因为是升序的)。根据这点就可以进行二分搜索了。这里min = mid + 1的条件
是citations[mid] < n - mid,确保退出循环时min肯定是指向一个有效哦的H指数。
程序设计:

public class Solution {
public int hIndex(int[] citations) {
int n = citations.length;
if(n == 0) return 0;
int min = 0, max = citations.length - 1;
while(min <= max){
int mid = (min + max) / 2;
// 如果该点是有效的H指数,则最大H指数一定在右边
if(citations[mid] < n - mid){
min = mid + 1;
// 否则最大H指数在左边
} else {
max = mid - 1;
}
}
// n - min是min点的H指数
return n - min;
}
}

  

H指数的更多相关文章

  1. [LeetCode] H-Index 求H指数

    Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...

  2. [Swift]LeetCode274.H指数 | H-Index

    Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...

  3. [Swift]LeetCode275. H指数 II | H-Index II

    Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a ...

  4. Leetcode 274.H指数

    H指数 给定一位研究者论文被引用次数的数组(被引用次数是非负整数).编写一个方法,计算出研究者的 h 指数. h 指数的定义: "一位有 h 指数的学者,代表他(她)的 N 篇论文中至多有 ...

  5. 275 H-Index II H指数 II

    这是 H指数 进阶问题:如果citations 是升序的会怎样?你可以优化你的算法吗? 详见:https://leetcode.com/problems/h-index-ii/description/ ...

  6. 274 H-Index H指数

    给定一位研究者的论文被引用次数的数组(被引用次数是非负整数).写一个方法计算出研究者的H指数.H-index定义: “一位科学家有指数 h 是指他(她)的 N 篇论文中至多有 h 篇论文,分别被引用了 ...

  7. Leetcode之二分法专题-275. H指数 II(H-Index II)

    Leetcode之二分法专题-275. H指数 II(H-Index II) 给定一位研究者论文被引用次数的数组(被引用次数是非负整数),数组已经按照升序排列.编写一个方法,计算出研究者的 h 指数. ...

  8. [LeetCode] 274. H-Index H指数

    Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...

  9. [LeetCode] 275. H-Index II H指数 II

    Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize ...

随机推荐

  1. 知名公司的GitHub地址

    GoogleGoogle[https://github.com/google]( https://github.com/google) Google Sampleshttps://github.com ...

  2. salt 配置管理

    索引 saltstack入门 salt state sls 描述文件 saltstack配置管理高级功能 saltstack入门 192.168.86.3 salt 修改 [root@Zabbix-s ...

  3. 【python-HTMLTestRunner】HTMLTestRunner测试报告中文乱码问题解决

    打开HTMLTestRunner.改动如图所示行 改成‘utf-8’

  4. Cura - CuraEngine - 架构分析

    参考: https://blog.csdn.net/justdoithai/article/details/52746094

  5. MySQL 基础--时间戳类型

    时间戳数据存储 .TimeStamp的取值范围为'1970-01-01 00:00:01' UTC 至'2038-01-19 03:14:07' UTC: .在存储时间戳数据时先将数据转换为UTC时区 ...

  6. 美团2018年CodeM大赛-初赛B轮 C题低位值

    试题链接:https://www.nowcoder.com/acm/contest/151/C 定义lowbit(x) =x&(-x),即2^(p-1) (其中p为x的二进制表示中,从右向左数 ...

  7. 从零开始的程序逆向之路 第一章——认识OD(Ollydbg)以及常用汇编扫盲

    作者:Crazyman_Army 原文来自:https://bbs.ichunqiu.com/thread-43041-1-1.html 0×00 序言: 1.自从上次笔者调戏完盗取文件密码大黑客后, ...

  8. HttpRunner框架(一)

    HttpRunner 是一款面向 HTTP(S) 协议的通用测试框架,只需编写维护一份 YAML/JSON 脚本,即可实现自动化测试.性能测试.线上监控.持续集成等多种测试需求. 中文使用文档地址:h ...

  9. 第二篇:服务消费者(RestTemplate+ribbon)

    第一篇讲了服务的注册,这篇来说说服务的调用,服务与服务的通讯是基于http restful,springcloud的服务调用是通过ribbon方式的,客户端的负载均衡. Talk is cheap.S ...

  10. vsftpd3.0.3配置

    2019.2.18更新 证实可用!!! 原文: 这两天测试在Ubuntu18.04上搭建一个ftp服务器,搜了一下大家都在用vsftpd,于是根据这个大佬的基础教程搭了一个,搭完一切正常,在windo ...