共计 206 个字符,预计需要花费 1 分钟才能阅读完成。
var search = function(nums, target) {
let start = 0
let end = nums.length - 1
while(start <= end) {let mid = Math.floor((start + end)/2)
if (target < nums[mid]) {end = mid - 1} else if (target > nums[mid]) {start = mid + 1} else {return mid}
}
return -1
};
正文完
发表至: javascript
2021-09-06