H指数
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指数的更多相关文章
- [LeetCode] H-Index 求H指数
Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...
- [Swift]LeetCode274.H指数 | H-Index
Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...
- [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 ...
- Leetcode 274.H指数
H指数 给定一位研究者论文被引用次数的数组(被引用次数是非负整数).编写一个方法,计算出研究者的 h 指数. h 指数的定义: "一位有 h 指数的学者,代表他(她)的 N 篇论文中至多有 ...
- 275 H-Index II H指数 II
这是 H指数 进阶问题:如果citations 是升序的会怎样?你可以优化你的算法吗? 详见:https://leetcode.com/problems/h-index-ii/description/ ...
- 274 H-Index H指数
给定一位研究者的论文被引用次数的数组(被引用次数是非负整数).写一个方法计算出研究者的H指数.H-index定义: “一位科学家有指数 h 是指他(她)的 N 篇论文中至多有 h 篇论文,分别被引用了 ...
- Leetcode之二分法专题-275. H指数 II(H-Index II)
Leetcode之二分法专题-275. H指数 II(H-Index II) 给定一位研究者论文被引用次数的数组(被引用次数是非负整数),数组已经按照升序排列.编写一个方法,计算出研究者的 h 指数. ...
- [LeetCode] 274. H-Index H指数
Given an array of citations (each citation is a non-negative integer) of a researcher, write a funct ...
- [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 ...
随机推荐
- Linux下强制杀死进程的方法
常规篇: 首先,用ps查看进程,方法如下: $ ps -ef …… smx 1822 1 0 11:38 ? 00:00:49 gnome-terminal smx 1823 1822 0 11:38 ...
- python_day1 条件语句
一 流程控制 1.if....else 语句 用法: if 条件: 满足条件执行代码 else: if 条件不满足执行此部分代码 例: a = 10 b = 20 if a>b : pri ...
- Codeforces Round #512 (Div. 2) D. Vasya and Triangle
参考了别人的思路:https://blog.csdn.net/qq_41608020/article/details/82827632 http://www.cnblogs.com/qywhy/p/9 ...
- Latex 模版生成会议论文 不显示Keywords,而是显示 Index Terms- ,改成Keywords 方法
一. 不管显示何种内容,TEX 文件都是 \begin{IEEEKeywords} 关键词1.关键词2,..... \end{IEEEKeywords} 其中:模版文件 IEEETran.cls存在下 ...
- Visual Stuido快捷键
转自:http://www.cnblogs.com/TankXiao/p/3164995.html 整理了一些VS的快捷键 格式化整个文档:(Ctrl + K, Ctrl + D)智能感知:(Ctrl ...
- weblogic安装及配置
WebLogic是用于开发.集成.部署和管理大型分布式Web应用.网络应用和数据库应用的Java应用服务器. 1.安装Weblogic:(1)点击Next按钮:(2) 选择Custom后点击Next按 ...
- js脚本实现自动上传至github
概述 如果要进行多次上传,使用git gui也会不方便,所以我总结了一下用npm的simple-git实现自动上传至github的方法.供以后开发时参考,相信对其他人也有用. 前提条件 需要安装nod ...
- 处理ios的overflow滚动bug
先说说这个bug的场景 .container{ height:100vh; overflow-y:scroll; } 没毛病,总有这种类似的情况,需要在容器内滚动,但是!这种容器内的滚动在ios上面处 ...
- DBUtils的增删改查
数据准备: CREATE DATABASE mybase; USE mybase; CREATE TABLE users( uid INT PRIMARY KEY AUTO_INCREMENT, us ...
- Redis简明教程
redis是什么: Redis is an open source, BSD licensed, advanced key-value store. It is often referred to a ...