Moving average
Computing the running -element moving average over an array of length efficiently takes:
Show hints (2)+
- Don't recompute each window from scratch.
- Add the entering element, subtract the leaving one.
Answer
Reveal answer →Final answer
O(m) with a sliding-window sum
Want the full step-by-step worked solution? It's part of Premium — along with a worked solution for every question in the bank.