func hIndex(citations []int) int {
	n := len(citations)
	index := make([]int, n+1)
	for _, c := range citations {
		if n <= c {
			index[n]++
		} else {
			index[c]++
		}
	}
	for i := n; 1 <= i; i-- {
		if i <= index[i] {
			return i
		}
		index[i-1] += index[i]  // So smart! The citations of h is the accumulation of index[h]~index[n]
	}
	return 0
}