Dsa
Two Pointers
Hard
Pond Water Levels
You are given a list of integers representing water levels in a pond at a series of checkpoints. Each integer indicates the level of water at that point, and you need to find the maximum water level difference between any two checkpoints where the second checkpoint occurs after the first one. Implement a function that determines this maximum difference.
Input format:
- The first line contains an integer n (1 ≤ n ≤ 10^5), the number of checkpoints.
- The second line contains n space-separated integers (0 ≤ water_level_i ≤ 10^6) representing the water levels.
Output format:
- Output a single integer, the maximum water level difference.
Example:
Input:
5
3 1 4 1 5
Output:
4
Key concepts
two_pointersarrayssliding_window
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