class Solution:
def solve(self, array):
lo, hi = 0, len(array)
while lo < hi:
mid = lo + (hi - lo) // 2
if some_condition:
hi = mid
else
lo = mid + 1
return lo
模板系列-二分法
最新推荐文章于 2024-08-29 22:25:44 发布
class Solution:
def solve(self, array):
lo, hi = 0, len(array)
while lo < hi:
mid = lo + (hi - lo) // 2
if some_condition:
hi = mid
else
lo = mid + 1
return lo