713. Subarray Product Less Than K
On This Page
class Solution:
def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
res, s, j = 0, 1, 0
for i, v in enumerate(nums):
s *= v
while j <= i and s >= k:
s //= nums[j]
j += 1
res += i - j + 1
return res