Skip to content

Commit 23d8c7a

Browse files
committed
find minimun in rotated sorted array solved
1 parent 5d096bd commit 23d8c7a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public int findMin(int[] nums) {
3+
int start = 0;
4+
int end = nums.length-1;
5+
6+
7+
while(start < end){
8+
int mid = (start + end) / 2;
9+
10+
if(nums[mid] < nums[end]){
11+
end = mid;
12+
}
13+
else{
14+
start = mid + 1;
15+
}
16+
}
17+
18+
return nums[start];
19+
}
20+
}
21+

0 commit comments

Comments
 (0)