Skip to main content

Practice · 2 of 5

Price Spikes

CHALLENGE
Difficulty: intermediate+25 XP

**Description:** Given n daily prices, count the days that are strict local maxima: higher than BOTH neighbors (day 1 and day n have only one neighbor). **Input:** Line 1: n (1 <= n <= 200000). Line 2: n integers (|p[i]| <= 10^9). **Output:** One integer — the number of strict local maxima. **Example:** 5 / 1 3 2 3 1 -> 2.

Back to lesson: Practice: Mixed Mock Problems