Question bank › Monotonic Stack
Dsa Monotonic Stack Hard

Mountain Peak Count

Given an array of heights representing mountains, determine the total number of peaks in the array. A peak is defined as an element that is greater than its immediate neighbors. Note that the first and last elements cannot be peaks. For example, for the input [1, 3, 2, 4, 1], the output should be 2, since 3 and 4 are peaks. Example: Input: 5 1 3 2 4 1 Output: 2

Key concepts

monotonic_stackarraypeaks

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.