We’re preparing your current view and syncing the latest data.
Given an array of positive integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k.
An array of positive integers nums, and an integer k.
An integer representing the count of contiguous subarrays with product less than k.
1 <= nums.length <= 3 * 10^4 1 <= nums[i] <= 1000 0 <= k <= 10^6
Example 1
Input
nums = [10, 5, 2, 6], k = 100
Output
8
Explanation
The 8 subarrays that have product less than 100 are: [10], [5], [2], [6], [10,5], [5,2], [2,6], [5,2,6].