Skip to content
Onsite

Signal's Capacity / Financial Problem

MediumP3Coding

A signal tower records strength[i] on day i. The capacity of day i is the number of consecutive days ending at day i (counting day i itself) whose strength is less than or equal to strength[i]. This is the classic stock span problem.

Return the capacity of every day.

Example 1

Input
strength = [100,80,60,70,60,75,85]
Output
[1,1,1,2,1,4,6]

Example 2

Input
strength = [10,20,30]
Output
[1,2,3]

Example 3

Input
strength = [30,20,10]
Output
[1,1,1]

Constraints

  • 0 <= strength.length <= 10^5
  • 1 <= strength[i] <= 10^9

Hints

Run checks the 3 visible tests, Submit all 10.