Dsa
Two Pointers
Medium
Wave Peak Detection
You are given an elevation profile as a list of integers representing heights at consecutive positions along a horizontal line. A peak is defined as an elevation that is higher than its neighbors. Your task is to find the longest sequence of peaks in the elevation profile.
Input: The first line contains an integer n (1 <= n <= 100,000), the number of elevation points. The second line contains n space-separated integers representing the elevation profile.
Output: Print the length of the longest contiguous sequence of peaks.
Example:
Input:
10
1 3 2 5 4 6 7 5 4 8
Output:
5
Key concepts
two_pointersarrayssorting
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