Imagine you're a city planner working on optimizing street lighting for a perfectly straight road. The street is represented by positions from 0 to n-1, and you have several street lamps installed at various positions.
Here's the challenge: Each street lamp at position i with range r illuminates all positions from max(0, i-r) to min(n-1, i+r). The brightness of any position is simply the number of street lamps that light it up.
You're given a requirement array where requirement[i] specifies the minimum brightness needed at position i. Your task is to count how many positions meet their brightness requirements.
For example, if position 3 needs at least 2 lamps to light it up, and currently 3 lamps illuminate that position, then position 3 satisfies its requirement.
Input & Output
Constraints
- 1 โค n โค 105
- 0 โค lights.length โค 105
- lights[i].length == 2
- 0 โค positioni < n
- 0 โค rangei โค 109
- requirement.length == n
- 0 โค requirement[i] โค 105