Movatterモバイル変換


[0]ホーム

URL:


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

Commit7c87047

Browse files
852_Peak_Index_in_a_Mountain_Array.java
1 parentb48fcb4 commit7c87047

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
classSolution {
2+
// public int peakIndexInMountainArray(int[] A) {
3+
// int i = 0;
4+
// for (; A[i] < A[i + 1]; i++);
5+
// return i;
6+
// }
7+
8+
publicintpeakIndexInMountainArray(int[]A) {
9+
intlo =0,hi =A.length -1;
10+
while (lo <hi) {
11+
intmid = (lo +hi) /2;
12+
if (A[mid] <A[mid +1])lo =mid +1;
13+
elsehi =mid;
14+
}
15+
returnlo;
16+
}
17+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp