Moving Average From Data Stream - Python Solution @ LeetCode
Moving Average From Data Stream, is a LeetCode problem. In this post we will see how we can solve this challenge in Python
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.
MovingAverage m = new MovingAverage(3); m.next(1) = 1 m.next(10) = (1 + 10) / 2 m.next(3) = (1 + 10 + 3) / 3 m.next(5) = (10 + 3 + 5) / 3 ....
You can find the full details of the problem Moving Average From Data Stream at LeetCode
Solution: Please check the main.py snippet for the solution.
This solution originally posted at: Github by @kamyu104