For each day i, the span is the number of consecutive days ending at day i (including day i) whose price was less than or equal to prices[i].
For [100, 80, 60, 70, 60, 75, 85] the spans are [1, 1, 1, 2, 1, 4, 6].
The starter code walks back from every day. It is correct but too slow for long lists.
Example 1
Input:
stock_span([100, 80, 60, 70, 60, 75, 85])
Output:
[1, 1, 1, 2, 1, 4, 6]
Example 2
Input:
stock_span([1, 2, 3])
Output:
[1, 2, 3]
0 <= len(prices) <= 2000001 <= prices[i] <= 10**9No results yet
Run your code to check it against the examples, or submit to run every test.