二分查找
作者:互联网
https://www.nowcoder.com/practice/d3df40bd23594118b57554129cadf47b?tpId=295&tqId=1499549&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj%3Ftab%3D%25E7%25AE%2597%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D295
func search( nums []int , target int ) int { // write code here le:=0;ri:=len(nums)-1 mid:=(le+ri)/2 for le<=ri{ if nums[mid]==target{ return mid } if nums[mid]>target{ ri=mid-1 }else{ le=mid+1 } mid=(le+ri)/2 } return -1 }
标签:二分,le,nums,int,mid,查找,25E7%,ri 来源: https://www.cnblogs.com/-citywall123/p/16445781.html