[LeetCode][JavaScript]H-Index

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.

Hint:

  1. An easy approach is to sort the array first.
  2. What are the possible values of h-index?
  3. A faster approach is to use extra space.

https://leetcode.com/problems/h-index/

 

 


 

 

h因子,万能的百度百科剧透了解法...

h代表“高引用次数”(high citations),一名科研人员的h指数是指他至多有h篇论文分别被引用了至少h次。

要确定一个人的h指数非常容易,到SCI网站,查出某个人发表的所有SCI论文,让其按被引次数从高到低排列,往下核对,直到某篇论文的序号大于该论文被引次数,那个序号减去1就是h指数。

 H-Index II: http://www.cnblogs.com/Liok3187/p/4782660.html

 

 1 /**
 2  * @param {number[]} citations
 3  * @return {number}
 4  */
 5 var hIndex = function(citations) {
 6     citations = citations.sort(sorting);
 7     var i = 0;
 8     while(i + 1 <= citations[i]){
 9         i++;
10     }
11     return i;
12 
13 
14     function sorting(a, b){
15         return b - a;
16     }
17 };

 

 

 

 

 

posted @ 2015-09-05 01:23  `Liok  阅读(577)  评论(0编辑  收藏  举报