File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
docs/Leetcode_Solutions/Python Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -56,3 +56,32 @@ class Solution(object):
5656 pivot = nums[i]
5757 return nums[0 ]
5858```
59+
60+
61+ > 思路 2
62+ ****** - 时间复杂度: O(lgN)****** - 空间复杂度: O(1)******
63+
64+
65+ 二分法,思路看代码一目了然,[ leetcode第33题] ( https://github.com/apachecn/awesome-algorithm/blob/master/docs/Leetcode_Solutions/Python/033._search_in_rotated_sorted_array.md ) 这道题很类似,我画了图的,可以看看
66+
67+ beats 100%
68+
69+ ``` python
70+ class Solution (object ):
71+ def findMin (self , nums ):
72+ """
73+ :type nums: List[int]
74+ :rtype: int
75+ """
76+ l, r = 0 , len (nums) - 1
77+ while l <= r:
78+ mid = l + ((r- l) >> 1 )
79+ if nums[mid] < nums[mid- 1 ]:
80+ return nums[mid]
81+ elif nums[mid] < nums[l]:
82+ r = mid - 1
83+ elif nums[mid] > nums[r]:
84+ l = mid + 1
85+ else :
86+ return nums[l]
87+ ```
You can’t perform that action at this time.
0 commit comments