Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher's h-index. The h-index is defined as the maximum value of h such that the given researcher has published at least h papers that have each been cited at least h times.
Example 1
Input: citations = [3,0,6,1,5]
Output: 3
Explanation: Sorted from highest, the citations are 6, 5, 3, 1, 0. Three papers have at least 3 citations each, but there are not four papers with at least 4, so h = 3.
Example 2
Input: citations = [1,3,1]
Output: 1
Explanation: Only one paper has at least 2 citations, but all three have at least 1. So h = 1.
Example 3
Input: citations = [0]
Output: 0
Explanation: The only paper has 0 citations, so h = 0.
Sort citations from most-cited to least. After sorting, the paper at 0-based index i is the (i+1)th most cited. The h-index is the largest i+1 for which that paper still has at least i+1 citations.
Run checks all cases above. Submit evaluates all test cases.