Skip to content

Commit fd90314

Browse files
committed
fixs haoel#4
1 parent f610c45 commit fd90314

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/findMinimumInRotatedSortedArray/findMinimumInRotatedSortedArray.II.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ int findMin(vector<int> &num) {
4848
}
4949
//binary search
5050
int mid = low + (high-low)/2;
51+
//If the array is not rotated then return num[low]
5152
//Notes: checking the equal situation
5253
if (num[low] <= num[mid] && num[mid] <= num[high]){
53-
return num[low] < num[mid] ? num[low] : num[mid];
54+
return num[low];
5455
}
5556
//move the high pointer to the middle, if sub-array from low to mid is rotated.
5657
if (num[low] > num [mid]){

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy