Indeed | Onsite | Whiteboard
Anonymous User
2329
  1. record(11) --- record(15) ---record(5) ---record(1)----mean()
    |----------------|--------------|-------------|-------------|

  2. record(11) --- record(15) ---record(5) ---record(1)----mean()----mean()
    |----------------|--------------|-------------|-------------|----------|

Here every PIPE(|) is the 1 minute time interval when the record/mean function is beign called.

The record() function saves the number and mean() function calculates the mean for the last 5 minute window. NOTE: mean() also has the time window included.

in case of the 1st test case , the last function called is mean() and the output would be (11+15+5+1)/4
in case of the 2nd test case , the last function called is mean() and the output would be (15+5+1)/3

Write the record and mean function, where record function shld only insert the value

Comments (8)