Skip to content

Commit c77c370

Browse files
aQuaaQua
aQua
authored and
aQua
committed
improve Problem 33
添加了一些注释
1 parent 5525bd5 commit c77c370

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Algorithms/0033.search-in-rotated-sorted-array/search-in-rotated-sorted-array.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ func search(nums []int, target int) int {
2222
if index >= length {
2323
index -= length
2424
}
25+
// 假设nums是由升序切片old转换来的
26+
// 那么,old[median] == nums[index]
2527

2628
// 传统二分查找法的比较判断
29+
// 原先需要old[median]的地方,使用nums[index]即可
2730
switch {
2831
case nums[index] > target:
2932
high = median - 1

0 commit comments

Comments
 (0)