题目:
题解:
class Solution:def hIndex(self, citations: List[int]) -> int:left,right = 0,len(citations)while left<right:# +1 防止死循环mid = (left+right+1)>>1cnt = 0for v in citations:if v>=mid:cnt+=1if cnt>=mid:# 要找的答案在 [mid,right] 区间内left=midelse:# 要找的答案在 [0,mid) 区间内right=mid-1return left