[抄题]:

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."

Example:

Input: citations = [3,0,6,1,5]
Output: 3
Explanation: [3,0,6,1,5] 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.

[暴力解法]:

时间分析:

空间分析:

[优化后]:

时间分析:

空间分析:

[奇葩输出条件]:

[奇葩corner case]:

[思维问题]:

以为n篇文章的引用量,有什么相互关系:并没有

[一句话思路]:

[输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入):

[画图]:

[一刷]:

  1. 累加数组元素的时候最好用一个新的sum 变量,也不占空间。加到数组元素上容易出现范围错误。

[二刷]:

[三刷]:

[四刷]:

[五刷]:

[五分钟肉眼debug的结果]:

[总结]:

[复杂度]:Time complexity: O(就是n) Space complexity: O(n)

[英文数据结构或算法,为什么不用别的数据结构或算法]:

这题比较特殊,数组元素 = 个数(也可以理解为桶排序)

计数排序(Counting sort)是一种稳定的线性时间排序算法。
计数排序使用一个额外的数组 {\displaystyle C} C ,其中第i个元素是待排序数组 {\displaystyle A} A中值等于 {\displaystyle i} i的元素的个数。
然后根据数组 {\displaystyle C} C 来将 {\displaystyle A} A中的元素排到正确的位置。

[算法思想:递归/分治/贪心]:

[关键模板化代码]:

//for loop : add to bucket
for (int c : citations) {
if (c > n) bucket[n]++;
else bucket[c]++;
}

[其他解法]:

[Follow Up]:

排序后:

[LC给出的题目变变变]:

[代码风格] :

class Solution {
public int hIndex(int[] citations) {
//cc
if (citations == null || citations.length == 0) return 0; //ini: bucket[n + 1] form exception
int n = citations.length;
int[] bucket = new int[n + 1]; //for loop : add to bucket
for (int c : citations) {
if (c > n) bucket[n]++;
else bucket[c]++;
} //count from back
int count = 0;
for (int i = n; i >= 0; i--) {
count += bucket[i];
if (count >= i) return i;
} return 0;
}
}

274. H-Index论文引用量的更多相关文章

  1. 275. H-Index II 递增排序后的论文引用量

    [抄题]: Given an array of citations in ascending order (each citation is a non-negative integer) of a ...

  2. Java实现 LeetCode 274 H指数

    274. H指数 给定一位研究者论文被引用次数的数组(被引用次数是非负整数).编写一个方法,计算出研究者的 h 指数. h 指数的定义: "h 代表"高引用次数"(hig ...

  3. Leetcode 274.H指数

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

  4. HDU-6278-Jsut$h$-index(主席树)

    链接: https://vjudge.net/problem/HDU-6278 题意: The h-index of an author is the largest h where he has a ...

  5. ZFNet(2013)及可视化的开端

    目录 写在前面 网络架构与动机 特征可视化 其他 参考 博客:blog.shinelee.me | 博客园 | CSDN 写在前面 ZFNet出自论文< Visualizing and Unde ...

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

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

  7. 274 H-Index H指数

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

  8. 【论文阅读】CVPR2021: MP3: A Unified Model to Map, Perceive, Predict and Plan

    Sensor/组织: Uber Status: Reading Summary: 非常棒!端到端输出map中间态 一种建图 感知 预测 规划的通用框架 Type: CVPR Year: 2021 引用 ...

  9. H指数

    H指数是用来综合衡量学者发表论文的数量和质量的指标,若某学者共发表N篇论文,H指数是指存在h 篇论文至少每篇有h 引用量,剩下的N-h篇中,每篇都不超过h引用量 计算H指数的方法:1.排序法思路:先将 ...

随机推荐

  1. PHP设置脚本最大执行时间的三种方法

    php.ini 中缺省的最长执行时间是 30 秒,这是由 php.ini 中的 max_execution_time 变量指定,如果脚本需要跑很长时间,例如要大量发送电子邮件,或者分析统计大量数据,服 ...

  2. 初识php,开发环境的配置

    PHP开发环境配置和第一个PHP程序(phpStudy+PhpStorm) 第一步 下载phpStudy 首先,到phpStudy官网上下载最新的phpStudy版本. 第二步 安装phpStudy ...

  3. MOSS 2013研究系列---修改默认Logo

    开发SharePoint2013 的时候,系统里面有一个“SharePoint” 的logo,客户很少不满意,我们的系统不能出现产品的名称,如下图: 咋么修改呢,咨询了广大网友,给出了一个解决方案: ...

  4. Kossel的一种滑块位置计算方法

    做了一个小激光雕刻机之后,研究了一下这款3D打印机的结构和工作原理,一下就对这个运动过程很感兴趣,这三个杆是怎么联动使得喷头保持在一个平面上运动呢?打算先做一个架构,然后把激光器放在上面不是可以方便雕 ...

  5. java代码------实现从控制台输入整型,

    总结:主要是方法的调用不能错,比如浮点型,整型,字节型,so.on int ====hasNextInt() float--------hasNextfloat() short ====hasNext ...

  6. 利用nginx_push_stream_module实现服务器消息推送

    NGiNX_HTTP_Push_Module 是一个 Nginx 的扩展模块,它实现了 HTTP Push 和Comet server的功能.HTTP Push 被经常用在网页上主动推的技术,例如一些 ...

  7. H3C IRF2的三种配置情况

    H3C-IRF2-虚拟交换技术-强列鼻视看我文档不下载的呵呵.看了下面的东西你就会配IRF了. H3C-5120-HI  H3C-5120S   H3C5800 先到H3C官网上面看那些交换机支持IR ...

  8. 028:基于mysqldump备份脚本

    MySQL Backup and Recovery 一 MySQL Backup 1.功能 mysqldump全量和增量备份,通过最近一次备份刷新产生binlog来定位执行增量. 脚本下载地址 git ...

  9. 在CentOS 7中使用VS Code编译调试C++项目

    1. 安装VSCODE 见VSCode官方链接 https://code.visualstudio.com/docs/setup/linux#_rhel-fedora-and-centos-based ...

  10. 敌兵布阵hdu1166

    /* 敌兵布阵 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...