275. H 指数 II

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Solution:
def hIndex(self, citations: List[int]) -> int:
def search_II(check)->int: # h篇
left = 0
right = len(citations)
while left<=right:
mid = (left+right)>>1
if check(mid):
left = mid+1
else:
right = mid-1
return right
def check(x)->bool: # h 次
idx = bisect.bisect_left(citations,x)
if len(citations)-idx >= x:
return True
return False
return search_II(check)