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 2c75463 commit 62c5425Copy full SHA for 62c5425
find-minimum-in-rotated-sorted-array/JEONGBEOMKO.java
@@ -0,0 +1,22 @@
1
+class Solution {
2
+ /*
3
+ time complexity: O(log n)
4
+ space complexity: O(h)
5
+ */
6
+ public int findMin(int[] nums) {
7
+ int start = 0, end = nums.length - 1;
8
+
9
+ if (nums[start] < nums[end]) return nums[start];
10
11
+ while (start < end) {
12
+ int mid = start + (end - start) / 2;
13
14
+ if (nums[mid] < nums[end]) {
15
+ end = mid;
16
+ } else {
17
+ start = mid + 1;
18
+ }
19
20
+ return nums[start];
21
22
+}
0 commit comments