nums contains positive whole numbers. Count the contiguous subarrays whose product is strictly less than k.
For nums = [10, 5, 2, 6] and k = 100 the answer is 8.
The starter code multiplies out every subarray. It is correct but too slow when many subarrays qualify.
Example 1
Input:
count_product_less([10, 5, 2, 6], 100)
Output:
8
Example 2
Input:
count_product_less([1, 2, 3], 0)
Output:
0
0 <= len(nums) <= 2000001 <= nums[i] <= 10000 <= k <= 10**9No results yet
Run your code to check it against the examples, or submit to run every test.