Skip to content

Commit 97e8256

Browse files
pjpjqimhuay
authored andcommitted
Fix binary search bug (#9)
1 parent d83ea7a commit 97e8256

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

算法/题解-剑指Offer.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,9 @@ public:
702702
int lo = 0;
703703
int hi = rotateArray.size() - 1;
704704

705-
// 完全旋转,或者说没有旋转(不需要
706-
//if (rotateArray[lo] < rotateArray[hi])
707-
// return rotateArray[lo];
705+
// 完全旋转,或者说没有旋转(需要, e.g {1, 2}
706+
if (rotateArray[lo] < rotateArray[hi])
707+
return rotateArray[lo];
708708

709709
while (lo + 1 < hi) {
710710
int mid = lo + (hi - lo) / 2;

0 commit comments

Comments
 (0)