Subarray Product Less Than K
MediumSliding Window
Decode it first. Clues, constraints, pattern and plan before any code.Given an array of positive integers nums and an integer k, return the number of contiguous subarrays whose product is strictly less than k.
nums = [10, 5, 2, 6], k = 100 → 8
[10] [5] [2] [6] [10, 5] [5, 2] [2, 6] [5, 2, 6]
nums = [1, 2, 3], k = 0 → 0Constraints
1 <= nums.length <= 3 * 10^41 <= nums[i] <= 10000 <= k <= 10^6