题目:
题解:
func hIndex(citations []int) int {// 答案最多只能到数组长度left,right:=0,len(citations)var mid intfor left<right{// +1 防止死循环mid=(left+right+1)>>1cnt:=0for _,v:=range citations{if v>=mid{cnt++}}if cnt>=mid{// 要找的答案在 [mid,right] 区间内left=mid}else{// 要找的答案在 [0,mid) 区间内right=mid-1}}return left
}