FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithm/Week_02/id_115/Leetcode_153_115_java.java at master · feixiangcode/algorithm · GitHub
feixiangcode
/
algorithm
Public
forked from
algorithm001/algorithm
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithm
/
Week_02
/
id_115
/
Leetcode_153_115_java.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (29 loc) · 779 Bytes
Breadcrumbs
algorithm
/
Week_02
/
id_115
/
Leetcode_153_115_java.java
Copy path
File metadata and controls
30 lines (29 loc) · 779 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package
data
.
leetcode
;
/**
* 假设按照升序排序的数组在预先未知的某个点上进行了旋转。
* <p>
* ( 例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] )。
* <p>
* 请找出其中最小的元素。
* <p>
* 你可以假设数组中不存在重复元素。
*/
public
class
Leetcode153
{
/*
这个题相当于找到旋转点
*/
//[3,4,5,1,2]
public
int
findMin
(
int
[]
nums
) {
int
minIndex
=
0
;
for
(
int
i
=
0
;
i
<
nums
.
length
;
i
++) {
//表示后一个比前一个大
if
(
nums
[
i
] <=
nums
[
minIndex
]) {
if
(
minIndex
!=
i
) {
minIndex
=
i
;
break
;
}
}
}
return
nums
[
minIndex
];
}
}
Back
|
FazBrowse Home
|
New Git URL