Problems > Count Local Maxima > Editorial

Count Local Maxima — Solution & Editorial

Back to the Problem

Scan positions 2..N-1 and compare each element with its two neighbours.

Complexity: O(N)