Problem 3187 · Hard

Peaks in Array

Keep a Fenwick tree of peak marks, so a range count is one prefix difference and an update only re-checks three positions.

Open the interactive visualisation