Update moving_average.py

This commit is contained in:
marina 2023-08-07 18:57:15 -07:00 committed by GitHub
parent db7be11ea0
commit af264699b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,17 +3,13 @@
# author: bt3gl # author: bt3gl
''' '''
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. Given a stream of integers and a window size, calculate the moving average in the sliding window.
Implement the MovingAverage class:
MovingAverage(int size) Initializes the object with the size of the window size.
double next(int val) Returns the moving average of the last size values of the stream.
''' '''
class MovingAverage: class MovingAverage:
def __init__(self, size: int): def __init__(self, size: int):
self.queue = [] self.queue = []
self.size = size self.size = size