论文引用h指数

1、描述

给你一个整数数组 citations ,其中 citations[i] 表示研究者的第 i 篇论文被引用的次数。计算并返回该研究者的 h 指数。

根据维基百科上 h 指数的定义:h 代表“高引用次数” ,一名科研人员的 h 指数 是指他(她)至少发表了 h 篇论文,并且 至少 有 h 篇论文被引用次数大于等于 h 。如果 h 有多种可能的值,h 指数 是其中最大的那个。
链接

2、关键字

论文被引用的h指数

3、思路

1、直接把每篇论文的引用次数展开,构成一行,之后竖着统计检查,从左往右,更新h
2、进行排序,之后从大到小遍历,
需要满足2个条件
条件一:有至少h篇
条件二:h篇中每篇至少引用h次

排好序,又从大到小遍历,h++保证条件一,
其中直接比较判断保证条件二

4、notes

5、复杂度

时间:
方法一:O(N2)
方法二:O(nlogN)
空间:
方法1:O(N2)
方法二:O(n)数组长度

6、code

# 方法一:
class Solution {
public:
    int hIndex(vector<int>& citations) {
        int n = citations.size();
        int max_n = 0;
        for (auto r : citations) { // 求出最多引用次数,作为列
            if (r > max_n) {
                max_n = r;
            }
        }

        int res = 0;
        vector<vector<int>> vec(n, vector<int>(max_n, 0));
        for(int i = 0; i < n; i++) {  // 初始化vec二维数组
            for(int j = 0; j < max_n; j++) {
                if(j < citations[i] ) {
                    vec[i][j] = 1;
                } else{
                    break;
                }
            }
        }
        for(int j = 0; j < max_n; j++) { // 竖着看,去检查
            int tem = 0;
            for(int i = 0; i < n; i++) {
                if(vec[i][j] == 1) {
                    tem++;
                }
            }
            if(tem >= j + 1 && j + 1 > res) { // j从0开始,所以j+1
                res = j + 1;
            }
        }
        return res;
    }
};



方法二:
class Solution {
public:
    int hIndex(vector<int>& citations) {
        sort(citations.begin(), citations.end());
        int n = citations.size() - 1;
        int h = 0;
        while(n >= 0) {
            if(citations[n] > h) { // 这里是 > 没有=
                h++;
            }
            n--;
        }
        return h;
    }
};

相关推荐

  1. 论文引用h指数

    2024-07-09 20:08:03       29 阅读
  2. 数组|274. H 指数

    2024-07-09 20:08:03       57 阅读
  3. [leetcode 274][H指数]

    2024-07-09 20:08:03       36 阅读
  4. 274. H 指数

    2024-07-09 20:08:03       29 阅读
  5. leetcode274H指数

    2024-07-09 20:08:03       26 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 20:08:03       53 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 20:08:03       56 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 20:08:03       46 阅读
  4. Python语言-面向对象

    2024-07-09 20:08:03       57 阅读

热门阅读

  1. 强化学习(Reinforcement Learning,简称RL)

    2024-07-09 20:08:03       29 阅读
  2. npm证书过期问题

    2024-07-09 20:08:03       20 阅读
  3. GitHub使用教程(小白版)

    2024-07-09 20:08:03       16 阅读
  4. WebXR:Web上的虚拟与增强现实技术

    2024-07-09 20:08:03       28 阅读