FunctionRacerProblemsRace

Count Local Peaks

MediumNumPyPython

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems