滑窗
def numOfSubarrays(self, arr, k, threshold):
"""
:type arr: List[int]
:type k: int
:type threshold: int
:rtype: int
"""
l = 0
res = 0
for i in range(k):
res += arr[i]
if res / k >= threshold:
ans = 1
else:
ans = 0
for r in range(k,len(arr)):
res = res + arr[r] - arr[l]
if res / k >= threshold:
ans += 1
l += 1
return ans