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
Problem Description
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.
For example,
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
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login .