[Leetcode] [JavaScript] H-index

Source: Internet
Author: User

H-index

Given an array of citations (each citation was a non-negative integer) of a researcher, write a function to compute the RES Earcher ' s h-index.

According to the definition of H-index on Wikipedia: ' A scientist has index H if h of his/her N Papers has at least H citations each, and the other n−h papers has no more than H citation S each. "

For example, given citations = [3, 0, 6, 1, 5] , which means the researcher have papers in total and each of 5 them had received 3, 0, 6, 1, 5 Citatio NS respectively. Since the researcher have papers with at least citations each and the remaining both with 3 3 no more than 3 CIT Ations each, he h-index is 3 .

Note:if there was several possible values h for, the maximum one is taken as the h-index.

Hint:

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

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

H factor, the Almighty Baidu Encyclopedia play through the solution ...

H stands for "high citation" (Hi citations), a researcher's H index refers to at most H-papers which are quoted at least H times respectively.

To determine a person's H index is very easy, to the SCI site, to find out a person published all SCI papers, let it ranked from high to low by the cited number, check down, until the number of a paper is more than the number of citations, the number minus 1 is the H index.

H-index ii:http://www.cnblogs.com/liok3187/p/4782660.html

1 /**2 * @param {number[]} citations3 * @return {number}4  */5 varHindex =function(citations) {6citations =citations.sort (sorting);7     vari = 0;8      while(i + 1 <=Citations[i]) {9i++;Ten     } One     returnI; A  -  -     functionsorting (A, b) { the         if(A >b) { -             return-1; -}Else if(A <b) { -             return1; +}Else{ -             return0; +         } A     } at};

[Leetcode] [JavaScript] H-index

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.