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.
1 parent ec2ac76 commit c78a14dCopy full SHA for c78a14d
1 file changed
find-minimum-in-rotated-sorted-array/chjung99.java
@@ -0,0 +1,23 @@
1
+class Solution {
2
+ public int findMin(int[] nums) {
3
+ int left = 0;
4
+ int right = nums.length - 1;
5
+ int mid = (left + right) / 2;
6
+ while (left + 1 < right){
7
+ mid = (left + right) / 2;
8
+ if (nums[mid] > nums[right]) {
9
+ left = mid;
10
+ }
11
+ if (nums[mid] < nums[right]) {
12
+ right = mid;
13
14
15
16
+ if (nums[mid] > nums[right]) return nums[right];
17
+ else {
18
+ return nums[mid];
19
20
21
+}
22
+
23
0 commit comments