Package g0201_0300.s0274_h_index
Class Solution
java.lang.Object
g0201_0300.s0274_h_index.Solution
274 - H-Index.<p>Medium</p>
<p>Given an array of integers <code>citations</code> where <code>citations[i]</code> is the number of citations a researcher received for their <code>i<sup>th</sup></code> paper, return compute the researcher’s <code>h</code> <strong>-index</strong>.</p>
<p>According to the <a href="https://en.wikipedia.org/wiki/H-index" target="_top">definition of h-index on Wikipedia</a>: A scientist has an index <code>h</code> if <code>h</code> of their <code>n</code> papers have at least <code>h</code> citations each, and the other <code>n \u2212 h</code> papers have no more than <code>h</code> citations each.</p>
<p>If there are several possible values for <code>h</code>, the maximum one is taken as the <code>h</code> <strong>-index</strong>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> citations = [3,0,6,1,5]</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong></p>
<pre><code> [3,0,6,1,5] 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, their h-index is 3.
</code></pre>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> citations = [1,3,1]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == citations.length</code></li>
<li><code>1 <= n <= 5000</code></li>
<li><code>0 <= citations[i] <= 1000</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
hIndex
public int hIndex(int[] citations)
-