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 db0d430 commit 1fc5dcfCopy full SHA for 1fc5dcf
find-minimum-in-rotated-sorted-array/gitsunmin.ts
@@ -0,0 +1,19 @@
1
+/**
2
+ * https://leetcode.com/problems/find-minimum-in-rotated-sorted-array
3
+ * time complexity : O(log n)
4
+ * space complexity : O(1)
5
+ */
6
+
7
+function findMin(nums: number[]): number {
8
+ let left = 0;
9
+ let right = nums.length - 1;
10
11
+ while (left < right) {
12
+ const mid = Math.floor((left + right) / 2);
13
14
+ if (nums[mid] > nums[right]) left = mid + 1;
15
+ else right = mid;
16
+ }
17
18
+ return nums[left];
19
+};
0 commit comments