File tree
Expand file treeCollapse file tree1 file changed
+11
-0
lines changed Expand file treeCollapse file tree1 file changed
+11
-0
lines changed Original file line number | Diff line number | Diff line change |
---|
|
| 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 | +} |
You can’t perform that action at this time.
0 commit comments