Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1b69f41

Browse files
🐱(binary-search): 153. 寻找旋转排序数组中的最小值
1 parent 15e8c78 commit 1b69f41

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎docs/algorithm/research/binary-search/README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,28 @@ func searchMatrix(matrix [][]int, target int) bool {
389389
}
390390
```
391391

392+
## 153. 寻找旋转排序数组中的最小值
393+
394+
[原题链接](https://leetcode-cn.com/problems/find-minimum-in-rotated-sorted-array/)
395+
396+
### 思路
397+
398+
```python
399+
class Solution:
400+
def findMin(self, nums: List[int]) -> int:
401+
left = 0
402+
right = len(nums) - 1
403+
while left < right:
404+
mid = (left + right) // 2
405+
if nums[mid] < nums[right]:
406+
# mid 可能是最小值
407+
right = mid
408+
else:
409+
# 最小值在 mid 右侧
410+
left = mid + 1
411+
return nums[left]
412+
```
413+
392414
## 162. 寻找峰值
393415

394416
[原题链接](https://leetcode-cn.com/problems/find-peak-element/)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /