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 0320536 commit 6ce7641Copy full SHA for 6ce7641
find-minimum-in-rotated-sorted-array/samthekorean.py
@@ -0,0 +1,15 @@
1
+class Solution:
2
+ # TC: O(log(n)) - The search space is halved each round until the minimum is found
3
+ # SC: O(1) - Only a few extra variables are used regardless of input size
4
+ def findMin(self, nums: List[int]) -> int:
5
+ low, high = 0, len(nums) - 1
6
+
7
+ while low < high:
8
+ mid = (high + low) // 2
9
10
+ if nums[mid] > nums[high]:
11
+ low = mid + 1
12
+ else:
13
+ high = mid
14
15
+ return nums[low]
0 commit comments