713. 乘积小于K的子数组
作者:互联网
滑动窗口
class Solution:
def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
start = 0
sums = 1
ans = 0
for i in range(len(nums)):
sums = sums * nums[i]
while sums >= k and start <= i:
sums = sums // nums[start]
start = start + 1
if sums < k:
ans = ans + i-start+1
return ans
标签:乘积,nums,int,713,self,sums,start,数组,List 来源: https://blog.csdn.net/FeNGQiHuALOVE/article/details/115282711