Question bank › Monotonic Stack
Dsa Monotonic Stack Hard

Stock Price Spikes

You are given an array of stock prices where each element represents the price on a given day. A spike is defined as a day where the price is higher than all previous days. Calculate the number of spikes each day has and output the result in an array. The first element of the output should always be 1, indicating that the first day is a spike by default. For example, if the input prices are [100, 180, 120, 130, 70, 200], the output should be [1, 1, 0, 0, 0, 1]. Example: Input: 6 100 180 120 130 70 200 Output: 1 1 0 0 0 1

Key concepts

monotonic_stackarraystock_analysis

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.