We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d8c124b + 0dd8f8d commit 926361eCopy full SHA for 926361e
LeetCode/154. Find Minimum in Rotated Sorted Array II/Solution.java
@@ -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
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
18
19
+}
0 commit comments