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 90ecae0 commit ea4023bCopy full SHA for ea4023b
find-minimum-in-rotated-sorted-array/eunice-hong.ts
@@ -0,0 +1,15 @@
1
+
2
+/**
3
+ *
4
+ * Time Complexity: O(n)
5
+ * Space Complexity: O(1)
6
+ */
7
+function findMin(nums: number[]): number {
8
+ let index = 0;
9
+ // find the index of where the value is greater than the next value
10
+ while (nums[index] < nums[(index + 1) % nums.length]) {
11
+ index++;
12
+ }
13
+ // return the next value
14
+ return nums[(index + 1) % nums.length]
15
+};
0 commit comments