346. Moving Average from Data Stream

# 346. 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.

Example:

MovingAverage m = new MovingAverage(3);
m.next(1) = 1
m.next(10) = (1 + 10) / 2
m.next(3) = (1 + 10 + 3) / 3
m.next(5) = (10 + 3 + 5) / 3

## 解题方案

- 时间复杂度: O(1)- 空间复杂度: O(1)

beats 100%