Loading
Loading
A risk model multiplies the factors in a contiguous run of readings. A run is considered safe when its product is strictly below a threshold.
Return how many contiguous runs are safe. All readings are positive.
factors = [10, 5, 2, 6], limit = 100[10]product 10 — safe[10,5]50 — safe[10,5,2]100 — not below the limitwindow shrinks to [5,2]10 — safe, contributing 2 runs8Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
Eight contiguous runs have a product below 100.
Example 2
No product is below zero.