Dsa
Monotonic Stack
Medium
Mountain Range
Given an array of integers representing elevations of a mountain range, calculate the total area of 'mountains' formed by consecutive higher elevations. A mountain is considered any increasing sequence of heights followed by an immediate drop in height.
Input:
- A single line of space-separated integers representing the elevations.
Output:
- A single integer representing the total area of the mountains.
Example:
Input: 1 3 2 4 1
Output: 6
Key concepts
monotonic_stackarraygeometry
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