Question bank › Monotonic Stack
Dsa Monotonic Stack Medium

Product Price Inversions

You are analyzing the price of various products over time. You want to find out the number of price inversions for each product. A price inversion occurs when a product's price is greater than a later product's price. Input Format: - A single line with N (1 <= N <= 100,000) followed by N integers representing the product prices. Output Format: - A single line with N integers representing the count of inversions for each product's price. Example: Input: 4 4 3 2 1 Output: 3 2 1 0

Key concepts

monotonic_stackpricesinversions

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.