ProblemThe problem is to design something that can find the moving average of an integer column, the moving window will be set by initializing the constructor, and then if you want to get the moving average, a next function will be called, and this function will pass a new number in. next returns the current moving average after this number is put in.Input
["MovingAverage", "next", "next", "next", "next"]
[[3], [1], [10], [3], [5]]
Output
[null, 1.0, 5.5, 4.66667, 6.0]
Explanation
MovingAverage movingAverage = new MovingAverage(3);
movingAverage.next(1); // return 1.0 = 1 / 1
movingAverage.ne
...
继续阅读
(12)