Binary Search

二分查找初级:二分模板

  • 数组元素无重复
class Solution:
    def search(self, nums: List[int], target: int) -> int:
        if not nums or len(nums) == 0:
            return -1
        left, right = 0, len(nums) - 1
        while left + 1 < right …
more ...