Skip to content

Commit 95bc480

Browse files
authored
Create 1343-number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold.py
1 parent 9d4c0f4 commit 95bc480

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution:
2+
def numOfSubarrays(self, arr: List[int], k: int, threshold: int) -> int:
3+
res = 0
4+
curSum = sum(arr[:k-1])
5+
6+
for L in range(len(arr) - k + 1):
7+
curSum += arr[L + k - 1]
8+
if (curSum / k) >= threshold:
9+
res += 1
10+
curSum -= arr[L]
11+
return res

0 commit comments

Comments
 (0)