Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9c60e43

Browse files
authored
Create Find the Peaks.java
1 parent 25e2990 commit 9c60e43

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Easy/Find the Peaks.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public List<Integer> findPeaks(int[] mountain) {
3+
List<Integer> result = new ArrayList<>();
4+
for (int i = 1; i < mountain.length - 1; i++) {
5+
if (mountain[i] > mountain[i - 1] && mountain[i] > mountain[i + 1]) {
6+
result.add(i);
7+
}
8+
}
9+
return result;
10+
}
11+
}

0 commit comments

Comments
 (0)