Question bank › Monotonic Stack
Dsa Monotonic Stack Warm-up

Daily Price Drop

You are given an array where each element represents the price of a product on consecutive days. Write a program to determine for each day how many days will pass until the price drops. If the price never drops, represent that with a 0. Input format: - The first line contains an integer n (1 <= n <= 10000), the number of days. - The second line contains n integers (0 <= prices[i] <= 100), the prices on those days. Output format: - A single line with n integers, where each integer represents the number of days until the price drops for that day. Example: Input: 5 100 90 80 90 70 Output: 1 1 0 1 0

Key concepts

monotonic_stackarray

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.