The TransCompilator

Solved LeetCode program · 972 of 1,000

#1343 · Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold

Medium Array chunk-20.md

Original English source

The scores is a list of 2, 2, 2, 2, 5, 5, 5, and 8. The width is 3, while the threshold is 4, while the needed is 12. The total is 0, while the answer is 0.
For every spot from 0 to the last position of scores.
Increase total by item spot of scores. If spot is at least width, set total to total minus item (spot minus width) of scores. If spot is at least width minus 1 and total is at least needed, add 1 to answer.

Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

3