This commit is contained in:
krahets
2024-03-21 04:22:07 +08:00
parent 35a07170c0
commit cfdb743939
52 changed files with 292 additions and 290 deletions

View File

@ -105,7 +105,7 @@ comments: true
// 等价于查找 target 的插入点
let i = binarySearchInsertion(nums: nums, target: target)
// 未找到 target ,返回 -1
if i == nums.count || nums[i] != target {
if i == nums.endIndex || nums[i] != target {
return -1
}
// 找到 target ,返回索引 i