Question bank › Monotonic Stack
Dsa Monotonic Stack Hard

Price Volume Peaks

You're given an array of stock prices followed by their respective trading volumes. For each price, find the last day where the price was equal to or greater than the current price and the trading volume was at least the same or more than the current volume. If no such day exists, return -1. Print the last matching day indices corresponding to each price. Example: Input: 100 200 100 150 250 200 300 Output: -1 0 -1 0 3 4 5 Input format: A single line containing space-separated integers representing prices followed by corresponding trading volumes. Output format: A single line containing space-separated integers representing the last day indices matching the conditions for each price.

Key concepts

monotonic_stackprices_volumes

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.