Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold LeetCode solution in Python
1class Solution:2def numOfSubarrays(self, arr: List[int], k: int, threshold: int) -> int:3wstart = wsum = count = 045for wend in range(len(arr)):6wsum += arr[wend]78if wend >= k:9wsum -= arr[wstart]10wstart += 111if (wsum // k) >= threshold and (wend - wstart + 1) == k:12count += 113return count