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 bf46998 commit 61ec21aCopy full SHA for 61ec21a
1 file changed
find-minimum-in-rotated-sorted-array/freemjstudio.py
@@ -0,0 +1,19 @@
1
+class Solution:
2
+ def findMin(self, nums: List[int]) -> int:
3
+ min_value = 5000
4
+ # O(log n) 이므로 binary search
5
+ if len(nums) == 1:
6
+ return nums[0]
7
+ left = 0
8
+ right = len(nums) - 1
9
+
10
+ while left <= right:
11
+ mid = (left + right) // 2
12
+ min_value = min(nums[mid], min_value)
13
14
+ if nums[mid] > nums[right]:
15
+ left = mid + 1
16
+ else:
17
+ right = mid - 1
18
19
+ return min_value
0 commit comments