Skip to content

Commit 926361e

Browse files
authored
Merge pull request #1087 from Rahul8691/Rahul8691-patch-1
Added Solution for LeetCode Problem No. 154
2 parents d8c124b + 0dd8f8d commit 926361e

File tree

1 file changed

+19
-0
lines changed
  • LeetCode/154. Find Minimum in Rotated Sorted Array II

1 file changed

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

0 commit comments

Comments
 (0)