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 54fcea1 commit 3da533fCopy full SHA for 3da533f
βfind-minimum-in-rotated-sorted-array/yyyyyyyyyKim.pyβ
@@ -0,0 +1,24 @@
1
+class Solution:
2
+ def findMin(self, nums: List[int]) -> int:
3
+ """
4
+ μκ°λ³΅μ‘λ: O(log n) - μ΄μ§ νμ
5
+ 곡κ°λ³΅μ‘λ: O(1) - μΆκ° λ©λͺ¨λ¦¬ μμ
6
7
+
8
+ # μ΄μ§νμ
9
+ left = 0
10
+ right = len(nums) - 1
11
12
+ while left < right:
13
+ # μ€κ° μΈλ±μ€
14
+ mid = (left+right)//2
15
16
+ # μ΅μκ°μ΄ μ€λ₯Έμͺ½μ μμ
17
+ if nums[mid] > nums[right]:
18
+ left = mid + 1
19
+ # μ΅μκ°μ΄ μΌμͺ½(μ€κ°ν¬ν¨)μ μμ
20
+ else:
21
+ right = mid
22
23
+ # μ΅μ’ μ΅μκ°
24
+ return nums[left]
0 commit comments