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.
Input Format
Input is managed for you
Output Format
Output is managed for you
Constraints
1. 1 <= size <= 1000 2. -10^5 <= val <= 10^5
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
3 1 10 3 5
Output
1.0 5.5 4.66667 6.0