def bisearch(elems, key):
low = 0
high = len(elems) - 1
while low <= high:
mid = (low + high)//2
if key == elems[mid].key:
return elems[mid].value
if key < elems[mid].key:
high = mid - 1
else:
low = mid + 1
用python实现二分查找
程序员文章站
2024-03-17 14:34:58
...
上一篇: Adding Powers
下一篇: 牛客网机试题-放苹果