left
to 0 and right
to n - 1
, where n
is the length of the citations
array.left
is less than or equal to right
, perform the following steps:
a. Calculate mid
as the midpoint between left
and right
.
b. If citations[mid]
is equal to n - mid
, return n - mid
as the h-index.
c. If citations[mid]
is less than n - mid
, search the right half by setting left
to mid + 1
.
d. If citations[mid]
is greater than n - mid
, search the left half by setting right
to mid - 1
.n - left
.