Inventory Management


Submit solution

Points: 10
Time limit: 15.0s
Memory limit: 121M

Authors:
Problem type
Allowed languages
Python

Aim

An Inventory system that collects daily price quotes for some goods, and returns the span of that good's price for the current day.

The span of the good's price today is defined as the maximum number of consecutive days (starting from today and going backwards) for which the price of the goods was less than or equal to today's price.

For example, if the price of a good over the next 7 days were [110, 85, 65, 75, 65, 80, 90], then the goods spans would be [1, 1, 1, 2, 1, 4, 6].

Explanation of the Example:

if first day price is 110, then span is 1

If second day price is 85, then span is 1

If third day price is 65, then span is 1

If fourth day price is 75, then span is 2

If fifth day price is 65, then span is 1

If sixth day price is 80, then span is 4

If seventh-day price is 90, then span is 6

Test case:

Sample Input:

100

80

60

70

60

75

85

Output:

1

1

1

2

1

4

6


Comments

There are no comments at the moment.