Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 294 Bytes

File metadata and controls

17 lines (14 loc) · 294 Bytes

Binary Search

def binarySearch(nums, target):
    l, r = 0, len(nums) -1
    while l <= r:
        mid = l + ((r-l) >> 2)
        if nums[mid] > target:
            r = mid - 1
        elif nums[mid] < target:
            l = mid + 1
	else: 
	    return mid
    return -1