From 1ee0a7a7bfe13511b5ff0a14aab5a5bae512ab92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=93=E6=98=A5=E9=A3=8E?= <77157236+night-cruise@users.noreply.github.com> Date: Tue, 26 Dec 2023 16:40:57 +0800 Subject: [PATCH] Fix the issue of discusscomment 7938404 (#1006) --- codes/rust/chapter_searching/binary_search.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/rust/chapter_searching/binary_search.rs b/codes/rust/chapter_searching/binary_search.rs index 345266e9f..3db2ae8dd 100644 --- a/codes/rust/chapter_searching/binary_search.rs +++ b/codes/rust/chapter_searching/binary_search.rs @@ -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; }