We have sampling data. on each time we have a different sampling value:
Each sample is (time, value) -> list of samples [(t1,v1),...(tn,vn)]
Our job is to implement moving_avg(data, window_sec). Data -> list of samples [(t1,v1),...(tn,vn)] Windows_secs -> size of window in secs
Example input: data = [(1,2),(2,4),(3,3),(4,2),(6,8),(8,2),(12,1)]
moving_avg(data, 2) returns: [(1,2),(2,3),(3,3),(4,3),(6,5),(8,5),(12,1)]
moving_avg(data, 3) returns: [(1,2),(2,3),(3,3),(4,2.75),(6,4.33),(8,5),(12,1)]
How do I implement it in C# with the best time complexity? the interviewer told me I cannot use an additional space (I used in the interview in Dictionary)