35.二分查找:leetcode69

1
2
3
4
5
6
7
8
9
10
11

left, right =0, len(array) - 1
while left <= right:
mid = left + (right - left)/2
if array[mid] == target:
//find the target
break or return result
elif array[mid] < target:
left = mid + 1
else:
right = mid - 1

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×