Question bank › Monotonic Stack
Dsa Monotonic Stack Warm-up

Stock Price Improvement Days

Given an array of stock prices, for each day calculate how many days you would have to wait until the price is higher than it was on that day. If there is no future day where this happens, the value should be 0. Print the results as a space-separated string. Input Format: - A single line containing N followed by N space-separated integers representing stock prices. Output Format: - A single line with space-separated integers indicating the wait days. Example: Input: 5 5 3 1 4 6 Output: 1 2 1 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.