# Leetcode oj:h-index (H index)

Source: Internet
Author: User

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.

Feel this problem more like moving return, did not write out, saw others ' realization, the code is as follows:

`1 classSolution {2  Public:3     intHindex (vector<int>&citations) {4         intn =citations.size ();5vector<int>index (n +1,0);//notice this is n+1 .6          for(inti =0; I < n; ++i) {7             if(citations[i]>=N)8index[n]++;9             ElseTenindex[citations[i]]++; One         } A         if(Index[n] >= N)returnN; -          for(inti = citations.size ()-1; I >=0; --i) { -index[i]+=index[i+1]; the             if(Index[i] >=i) -                 returni; -         } -         return 0; +     } -};`

Leetcode oj:h-index (H index)

Related Keywords:

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.