def search(nums, target):
for i in range(len(nums)):
if nums[i] == target:
return i
if nums[i] == None:
return -1
I think this code will be good for most cases in binary search but in some cases might need a better version of the code that is O(log n)
.
0 <= i <= j < len(nums)
impliesnums[i] <= nums[j]
? \$\endgroup\$