Back to problems

Implement sliding-window timestamped average

Object-Oriented Programming · Bloomberg · Medium

Implement a function solution(window_size, operations) that processes a sequence of timestamped records in order. Each operation is one of: ("insert", timestamp, score): first remove every stored record whose timestamp is less than timestamp - window_size, then store the new record. ("get", current_time): first remove every stored record whose timestamp is less than current_time - window_size, then return the arithmetic mean of the scores of all remaining records. After…

Checking your access…