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 a87cf8a commit 77badffCopy full SHA for 77badff
โfind-minimum-in-rotated-sorted-array/pmjuu.pyโ
@@ -0,0 +1,22 @@
1
+'''
2
+์๊ฐ ๋ณต์ก๋: O(log n)
3
+- ์ด์ง ํ์์ ์ฌ์ฉํ์ฌ ๋งค ๋ฐ๋ณต๋ง๋ค ๊ฒ์ ๋ฒ์๋ฅผ ์ ๋ฐ์ผ๋ก ์ค์ด๋ฏ๋ก O(log n)์ ๋๋ค.
4
+
5
+๊ณต๊ฐ ๋ณต์ก๋: O(1)
6
+- ์ถ๊ฐ์ ์ธ ๋ฐฐ์ด์ด๋ ๋ฆฌ์คํธ๋ฅผ ์ฌ์ฉํ์ง ์๊ณ , ๋ช ๊ฐ์ ๋ณ์๋ง ์ฌ์ฉํ๋ฏ๋ก O(1)์ ๋๋ค.
7
8
9
+from typing import List
10
11
+class Solution:
12
+ def findMin(self, nums: List[int]) -> int:
13
+ left, right = 0, len(nums) - 1
14
15
+ while left < right:
16
+ mid = (left + right) // 2
17
+ if nums[mid] > nums[right]:
18
+ left = mid + 1 # ์ต์๊ฐ์ด ์ค๋ฅธ์ชฝ์ ์์
19
+ else:
20
+ right = mid # ์ต์๊ฐ์ด mid ๋๋ ์ผ์ชฝ์ ์์
21
22
+ return nums[left]
0 commit comments