Subarray Product Less Than K

Given an array of positive integers nums and an integer k, return the number of contiguous subarrays where the product is strictly less than k.

Input Format

nums = array of positive integers, k = threshold

Output Format

count of qualifying subarrays

Constraints

  • 1 <= nums.length <= 3*10^4; 1 <= nums[i] <= 1000; 0 <= k <= 10^6

Examples

Example 1:

Input:

nums = [10,5,2,6]
k = 100

Output:

8

Explanation:

The subarrays are [10],[5],[2],[6],[10,5],[5,2],[2,6],[5,2,6].

Loading...
Subarray Product Less Than K - Arrays