mirror of
https://github.com/krahets/hello-algo.git
synced 2025-02-02 14:18:47 +08:00
Fix the issue of discusscomment 7938404 (#1006)
This commit is contained in:
parent
774c27c47e
commit
1ee0a7a7bf
@ -35,7 +35,7 @@ fn binary_search_lcro(nums: &[i32], target: i32) -> i32 {
|
||||
if nums[m as usize] < target { // 此情况说明 target 在区间 [m+1, j) 中
|
||||
i = m + 1;
|
||||
} else if nums[m as usize] > target { // 此情况说明 target 在区间 [i, m) 中
|
||||
j = m - 1;
|
||||
j = m;
|
||||
} else { // 找到目标元素,返回其索引
|
||||
return m;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user