73. Stock Span
MediumMonotonic Stack
The span of day i is the number of consecutive days ending at day i (including it) on which the price was ≤ the price on day i. Print the span of every day.
Input format
Line 1: n Line 2: n prices
Output format
n spans.
Example 1
Input
7 100 80 60 70 60 75 85
Output
1 1 1 2 1 4 6
Example 2
Input
3 10 20 30
Output
1 2 3
Constraints
1 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.
Loading the MyLoginn IDE…