Dsa
Monotonic Stack
Medium
Trends in Data
You have a series of data points that represent measurements taken over time. Write a program that outputs for each data point the number of previous data points that were higher than the current data point.
Input Format:
- A single line containing space-separated integers representing the data points.
Output Format:
- A single line containing space-separated integers indicating the count of previous higher data points for each measurement.
Example:
Input:
10 5 8 3 1 4 6
Output:
0 1 1 3 4 3 2
Key concepts
monotonic_stacktrend_analysisdata_points
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