Dsa
Monotonic Stack
Hard
Customer Arrival Rates
You are tasked to analyze customer arrival rates at a store. Each element in the input array represents the number of customers arriving each minute. Create an output array where each position indicates the number of minutes until the next minute with an equal or higher number of customers. If there is no next minute, that position should be -1. For example, for input [5, 1, 3, 3, 8], the output would be [4, 2, 1, 1, -1].
Example:
Input:
5
5 1 3 3 8
Output:
4 2 1 1 -1
Key concepts
monotonic_stacksimulationqueue
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