0346. Moving Average from Data Stream
https://leetcode.com/problems/moving-average-from-data-stream
Description
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.
Implement the MovingAverage
class:
MovingAverage(int size)
Initializes the object with the size of the windowsize
.double next(int val)
Returns the moving average of the lastsize
values of the stream.
Example 1:
Constraints:
1 <= size <= 1000
-105 <= val <= 105
At most
104
calls will be made tonext
.
ac
Last updated