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 233036e commit e71b698Copy full SHA for e71b698
find-minimum-in-rotated-sorted-array/i-mprovising.py
@@ -0,0 +1,23 @@
1
+"""
2
+Time complexity O(logn)
3
+Space compexity O(1)
4
+
5
+Binary search
6
7
8
+class Solution:
9
10
+ def findMin(self, nums: List[int]) -> int:
11
+ start = 1
12
+ end = len(nums) - 1
13
14
+ while start <= end:
15
+ mid = (start + end) // 2
16
+ if nums[mid-1] > nums[mid]:
17
+ return nums[mid]
18
+ if nums[0] < nums[mid]:
19
+ start = mid + 1
20
+ else:
21
+ end = mid - 1
22
23
+ return nums[0]
0 commit comments