Question bank › Monotonic Stack
Dsa Monotonic Stack Easy

The Pressure Valve Dip

In a water pipe system, a series of valves have different pressure ratings. For each valve, find the pressure rating of the first valve to its right that has a strictly lower rating. This is used to detect pressure dips. If no such valve exists, output -1. Example: Ratings: [45, 30, 35, 20, 25] - Valve 0 (45): Next smaller is 30. Output 30. - Valve 1 (30): Next smaller is 20. Output 20. - Valve 2 (35): Next smaller is 20. Output 20. - Valve 3 (20): No smaller to the right. Output -1. - Valve 4 (25): No smaller to the right. Output -1. Result: 30 20 20 -1 -1

Key concepts

monotonic_stacknext_smaller_element

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.