Moving Average From Data Stream
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. Implement the MovingAverage class: 1. MovingAverage(int size) Initializes the object with the size of the window size. 2. double next(int val) Returns the moving average of the last size values of the stream.
1. 1 <= size <= 1000 2. -10^5 <= val <= 10^5
Input is managed for you
Output is managed for you
3 1 10 3 5
1.0 5.5 4.66667 6.0