【力扣】二分查找
二分查找笔记
class Solution {
public:
int search(vector
int low = 0 ;
int high = nums.size()-1; //记得长度减1
while(low <= high){
int mid = low + ( (high-low) /2 ) ; //等价于(low+high)/2
if(target < nums[mid])
high = mid- 1;
else if (target > nums[mid])
low = mid
【力扣】二分查找最先出现在Python成神之路。
共有 0 条评论