Skip to content

Latest commit

 

History

History
 
 

moving_average_from_data_stream

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Problem

Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.

For 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