`

H-Index

阅读更多
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因子(h-factor),是一种评价学术成就的新方法。h代表“高引用次数”(high citations),一名科研人员的h指数是指他至多有h篇论文分别被引用了至少h次, 剩余的论文引用的次数不多于h次。题目中给定了一个数组,数组的长度就代表了论文的个数,每个元素的值代表了引用的次数,让我们从中找到H-index.

首先我们设定h的初始值为1。然后我们将数组排序,从最后一个元素开始与h比较,1,如果比h大,就让h加1,继续往前比较,直到遇到等于或者小于h的情况;2, 如果等于h, 就返回h; 3,如果小于h, 就返回h - 1。在第1步中,如果一直都大于h, 我们就返回数组的长度。我们用到了排序,这样时间复杂度为O(nlogn)。代码如下:
public class Solution {
    public int hIndex(int[] citations) {
        if(citations == null || citations.length == 0) return 0;
        Arrays.sort(citations);
        int h = 1;
        for(int i = citations.length - 1; i >= 0; i--) {
            if(citations[i] > h) {
                h ++;
            } else if(citations[i] == h) {
                return h;
            } else {
                return h - 1;
            }
        }
        return citations.length;
    }
}


另外一种方法只用O(n)的时间复杂度就可以解决,但是我们要用到O(n)的空间。类似于计数排序的方法,创建一个数组count来记录文章引用次数的情况,然后从count的最后一个元素开始累加,当累加的数字大于或等于当前下标的时候就返回。代码如下:
public class Solution {
    public int hIndex(int[] citations) {
        if(citations == null || citations.length == 0) return 0;
        int len = citations.length;
        int[] count = new int[len + 1];
        for(int i = 0; i < len; i++) {
            if(citations[i] >= len) 
                count[len] ++;
            else
                count[citations[i]] ++;
        }
        for(int i = count.length - 1; i > 0; i--) {
            if(count[i] >= i) return i;
            count[i - 1] += count[i];
        }
        return 0;
    }
}
1
4
分享到:
评论

相关推荐

    H-index因子C++代码

    在网上没有搜到关于H-index因子的代码,于是自己写了个与大家分享。

    Modeling and Predicting the Increase of H-index

    对H-index的增长建模与预测,刘逸彬,李言辉,H-index(H指数)是一个在文献计量学领域被广泛使用的用来量化个人科学研究成果的指标。本文提出了一个描述H-index 增长的模型,并找出�

    Application of h-index on 5-year citations, complement the 5-year impact factor of high-citation paper.

    高引文章5年h-index的研究,王川奇,李言辉,在期刊质量评价研究中,许多学者提出了新的指数去辅助IF进行期刊学术质量的评价。但是在我们的研究中发现,并没有一个基于即时数据�

    Google Chrome:trade_mark:学者H指数计算器「Scholar H-Index Calculator for Google Chrome:trade_mark:」-crx插件

    Scholar H-Index Calculator是一种文献计量和引文分析工具,可作为Google Chrome浏览器的插件,在Google Scholar页面的顶部提供更多见解。使用方法:只需访问Scholar.google.com并进行查询。增强的信息将在常规的...

    HM-Index:工作室的官方网站

    您可以通过修改pages/index.js来开始编辑页面。 页面在您编辑文件时自动更新。 可以在上访问。 可以在pages/api/hello.js编辑此端点。 pages/api目录映射到/api/* 。 此目录中的文件被视为而不是React页面。 学到...

    H-ui.admin

    ├── index.html 首页(主框架) ├── welcome.html 我的桌面(默认永远打开的页面) ├── member-开头的 用户相关 ├── artice-开头的 资讯相关 ├── picture-开头的 图片相关 ├── product-开头的...

    H-ui.admin 前端框架

    H-ui.admin是用H-ui前端框架开发的轻量级网站后台模版 采用源生html语言,完全免费,简单灵活,兼容性好 让您快速搭建中小型网站后台 程序员的的福音 \根目录 │ _blank.html 空白页(每次我们都拿空白页去创建,...

    H-ui.admin_v2.3.1

    │ index.html 首页(主框架) │ welcome.html 我的桌面(默认永远打开的页面) │ member-开头的 用户相关 │ artice-开头的 资讯相关 │ picture-开头的 图片相关 │ product-开头的 产品相关 │ page-开头的 ...

    Roles of degree, H-index and coreness in link prediction of complex networks

    Roles of degree, H-index and coreness in link prediction of complex networks

    轻量级网站后台模版H-ui.admin.zip

    H-ui.admin是用H-ui前端框架开发的轻量级网站后台模版采用源生html语言,完全免费,简单灵活,兼容性好,让您快速搭建中小型网站...Demo地址:http://www.h-ui.net/H-ui.admin/v2.4/index.html 标签:后台模版

    H-ui前端框架系统

    H-ui前端框架系统是基于 HTML、CSS、JAVASCRIPT开发的轻量级web前端框架 http://www.h-ui.net/index.shtml 。这里是官方的网址,可以 免费下载的。我这里仅做保存一下。

    H-ui.admin v3.1后台模版

    ├── index.html 首页(主框架) ├── welcome.html 我的桌面(默认永远打开的页面) ├── member-开头的 用户相关 ├── artice-开头的 资讯相关 ├── picture-开头的 图片相关 ├── product-开头的...

    Index:H-Viewer的所有站点

    H-Viewer Sites All sites for H-Viewer 注:这个列表已不再更新,获取最新最全的站点请在应用内的站点市场 Sites ACG图站 —— ACG picture sites ID Site's Json QR Code Author 1 PureDark 2 PureDark & Booru图...

    ALTEGRAD-H-Index-prediction-challenge-:在此仓库中,您将找到我们用于ALTEGRAD课程竞赛的提交内容的笔记本

    ALTEGRAD H指数预测挑战 在此回购中,您将找到ALTEGRAD课程竞赛中用于提交的笔记本。

    ametric:基于 bibtex 文件生成作者级指标

    h -Index : h -Index 为h 的学者至少发表了h篇论文,每篇论文至少被引用了h次。 归一化的ħ -索引:A和NH的归一化ħ -索引学者由于第一纸张,其中的每一个已被引用至少NH倍已出版至少NH论文。 Per-Coauthor ...

    less-index:为LESS文件的目录创建一个入口点

    安装 # Globally – for a user:npm install --global less-index# …or locally – for a project:npm install --save-dev less-index用法概要 Usage: less-index [] ...&lt;directory&gt; or: less-index (-h|--help)...

    利用本地h指数来识别和排列网络中有影响力的吊具

    在本文中,我们提出了一种局部h-index中心度(LH-index)方法来识别和排序网络中的影响节点。 LH-index方法同时考虑了节点本身及其邻居的h-index值,这是基于这样一个想法,即连接到更具影响力的节点的节点也将具有...

    h index to quantify an scientist

    For the few scientists who earn a Nobel prize, the impact and relevance of their research is unquestionable. Among the rest of us, how does one quantify the cumulative impact and relevance of an ...

    apache h-base 权威指南

    Their indexing pipeline was an involved multistep process that produced an index about two orders of magnitude larger, on aver‐ age, than your standard term-based index. The datastore that they’d ...

    AI发展报告2019.pdf

    AMiner平台推荐了各领域代表性的期刊/会议,并由专家进行补充,挖掘这些期刊/会议近10年论文,确定了h-index排名前2000的学者,构建各领域学者库。我们将这些学者供职机构的位置信息绘制于地图上得到了学者分布地图...

Global site tag (gtag.js) - Google Analytics