描述
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:
1 | Input: citations = [3,0,6,1,5] |
Note: If there are several possible values for h, the maximum one is taken as the h-index.
分析
这题要求我们求H指数,思路不复杂,将某人发表的所有 SCI 论文按照引用次数从高到低排序,从高到低编号为 0,1,2 … n,当 n >= 引用数时,这个值就是某人的 H 指数。这个指数可以用来评估研究人员的学术产出数量和学术产出水平。
解决方案1(Java)
在 Java 中,自定义 int 类型的 compare 方法还得先把 int 转换成 Integer,见 https://stackoverflow.com/questions/7414299/sorting-int-array-in-descending-order ,索性用从低到高的顺序,只要序号对了就行。如果用 Python 就直观多了。
1 | class Solution { |
解决方案2(Python)
1 | class Solution: |