Cruise Interview Question

Design a class and member functions to compute n-interval moving average in C++.

Interview Answer

Anonymous

Aug 2, 2019

Use vectors to store last n elements. Everytime a new element comes in, push_back new elements and remove the first element and compute moving average.