Count Local Peaks
A peak is a position that is strictly higher than both its left and right neighbors. The first and last positions have only one neighbor, so they are never peaks. Return how many peaks heights has.
Example 1
heights [1,3,2,4,1]
returns 2
The 3 and the 4 are both peaks.
Constraints
1 <= len(heights) <= 100
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More NumPy problems
- Deepest Fall From a HighMedium
- Distance From a CellMedium
- Halfway PointMedium
- Highest Cell PositionMedium
- Matching PairsMedium
- Mean of Each GroupMedium
- Multiplication TableMedium
- Order by ScoreMedium