Skip to content

Commit eed59e1

Browse files
author
Chu Fan
committed
docs: update
1 parent d03479b commit eed59e1

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed

code/algorithm/剑指/二分查找/minNumberInRotateArray.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ function minNumberInRotateArray(rotateArray) {
88
if (rotateArray.length < 0) {
99
return 0
1010
}
11-
1211
for (let index = 0; index < rotateArray.length - 1; index++) {
1312
if (rotateArray[index] > rotateArray[index + 1]) {
1413
return rotateArray[index + 1]
1514
}
1615
}
17-
18-
// 返回
1916
return rotateArray[0]
2017
}
18+
Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,33 @@
1-
/**
2-
* 旋转数组的最小数字
3-
* 找出前者大于后者的数,立即返回
4-
* 难度:简单
5-
* @param rotateArray
6-
*/
7-
function minNumberInRotateArray (rotateArray) {
8-
if (rotateArray.length < 0) {
9-
return 0
10-
}
11-
12-
for (let index = 0; index < rotateArray.length - 1; index++) {
13-
if (rotateArray[index] > rotateArray[index + 1]) {
14-
return rotateArray[index + 1]
15-
}
16-
}
17-
18-
// 返回
19-
return rotateArray[0]
20-
}
21-
221
# 算法相关文档格式模版
232

24-
25-
26-
273
### 题目链接
284

29-
- [牛客网]()
5+
- [牛客网](https://www.nowcoder.com/practice/9f3231a991af4f55b95579b44b7a01ba)
306
- [欢迎讨论]()
317

328
### 题目描述
339

10+
有一个长度为 n 的非降序数组,比如[1,2,3,4,5],将它进行旋转,即把一个数组最开始的若干个元素搬到数组的末尾,变成一个旋转数组,比如变成了[3,4,5,1,2],或者[4,5,1,2,3]这样的。请问,给定这样一个旋转数组,求数组中的最小值。
11+
12+
数据范围:1≤n≤10000,数组中任意元素的值:0≤val≤10000
13+
14+
要求:空间复杂度:O(1) ,时间复杂度:O(logn)
15+
16+
17+
示例:
18+
19+
```bash
20+
#输入:
21+
[3,4,5,1,2]
22+
#返回值:
23+
1
24+
```
3425

3526
### 思路
3627

3728

3829
### 代码实现
3930

40-
@[code js](@code/algorithm/剑指/栈队列堆/firstAppearingOnce.js)
31+
@[code js](@code/algorithm/剑指/二分查找/minNumberInRotateArray.js)
4132

4233
### 一些建议

0 commit comments

Comments
 (0)