如果引用数为x,所在位置为i,那么至少有n-i个引用数不小于x。那么如果x不小于n-i,则意味着有可能取得更大的hIndex,最小符合h指数的边界应该向左移动
func hIndex(citations []int) int {
n := len(citations)
return n - sort.Search(n, func(i int) bool {
return citations[i] >= n-i
})
}
https://leetcode.cn/problems/h-index-ii/description/