码迷,mamicode.com
首页 > 编程语言 > 详细

[LeetCode][JavaScript]H-Index

时间:2015-09-05 06:33:28      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:

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         if(a > b){
16             return -1;
17         }else if(a < b){
18             return 1;
19         }else{
20             return 0;
21         }
22     }
23 };

 

 

 

 

 

[LeetCode][JavaScript]H-Index

标签:

原文地址:http://www.cnblogs.com/Liok3187/p/4782658.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!