Skip to content

fix(Update README.md):numbers[mid] == numbers[r] 并不能断定 numbers[mid] 一定不是最小值 #3730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lcof/面试题11. 旋转数组的最小数字/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/lcof/%E9%9D%A2%E8%AF%95%E9

- `numbers[mid] > numbers[r]`:中间元素一定不是最小值,因此 $l = mid + 1$;
- `numbers[mid] < numbers[r]`:中间元素可能是最小值,因此 $r = mid$;
- `numbers[mid] == numbers[r]`:中间元素一定不是最小值,因此 $r = r - 1$。
- `numbers[mid] == numbers[r]`:无法确定最小值的位置,但可以简单地缩小搜索范围,因此 $r = r - 1$。

循环结束时,指针 $l$ 和 $r$ 指向同一个元素,即为最小值。

Expand Down
Loading