1343. Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold - Medium
前往題目
想法
Sliding window
思路
簡單的那種固定window size
的
- 每次循環都更新總和
- 檢查平均,如果滿足
threshold
加入結果 - 循環結束前都移動左指針並且從
sum
減去相對應的數字
Code
1343. Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold - Medium
https://f88083.github.io/2024/07/30/1343-Number-of-Sub-arrays-of-Size-K-and-Average-Greater-than-or-Equal-to-Threshold/