values and a threshold limit. A window is a non-empty run of consecutive elements of the array.
Count the windows whose product of all elements is **strictly less** than limit. Windows with the same values at different positions count separately.
Checking every window takes O(n²); try to do it in O(n).values=[3, 4, 2, 10], limit=30 → 8
The windows [3], [4], [2], [10], [3, 4] (12), [4, 2] (8), [2, 10] (20) and [3, 4, 2] (24) qualify, 8 in total. [4, 2, 10] has product 80, which is too much.
values=[7, 7], limit=7 → 0
Even a single 7 is not below the limit 7, so the answer is 0.
values=[1, 1, 1], limit=2 → 6
Every window has product 1 < 2, and an array of length 3 has exactly 6 windows.
values=[3, 4, 2, 10], limit=30
8
Run checks the first 3 tests in your browser. Submit checks all 123 tests on the server, hidden ones included.