FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode/code/lc153.java at master · mJackie/leetcode · GitHub
mJackie
/
leetcode
Public
Notifications
You must be signed in to change notification settings
Fork
135
Star
405
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode
/
code
/
lc153.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (25 loc) · 650 Bytes
Breadcrumbs
leetcode
/
code
/
lc153.java
Copy path
File metadata and controls
25 lines (25 loc) · 650 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
package
code
;
/*
* 153. Find Minimum in Rotated Sorted Array
* 题意:反转数组找最小值
* 难度:Medium
* 分类:Array, Binary Search
* 思路:想清楚,不用那么多判断
* Tips:边界条件想清楚
* nums[mid]和nums[right]比就行了
*/
public
class
lc153
{
public
int
findMin
(
int
[]
nums
) {
int
left
=
0
;
int
right
=
nums
.
length
-
1
;
while
(
left
<
right
){
int
mid
= (
left
+
right
)/
2
;
if
(
nums
[
mid
]<
nums
[
right
]){
right
=
mid
;
//这不加1
}
else
{
left
=
mid
+
1
;
}
}
return
nums
[
left
];
}
}
Back
|
FazBrowse Home
|
New Git URL