标签:ret arch log 查找 print 实现 二分法 lis span
#二分查找 def search_val(data_list, val): left = 0 right = len(data_list) - 1 while left <= right: mid = (left + right) // 2 if data_list[mid] == val: return mid elif data_list[mid] > val: right = mid - 1 else: left = mid + 1 return -1 data_list = [1, 2, 3, 5, 6, 7, 8, 9, 12, 34, 45, 56, 66] val = 3 print(search_val(data_list, val))
标签:ret arch log 查找 print 实现 二分法 lis span
原文地址:http://www.cnblogs.com/zhaoyongjie/p/6901904.html