Used in ML monitoring: compute rolling maximum of a metric (loss, accuracy, latency) over a sliding window.
sliding_max([1,3,-1,-3,5,3,6,7], k=3) โ [3, 3, 5, 5, 6, 7]
Windows: [1,3,-1]โ3, [3,-1,-3]โ3, [-1,-3,5]โ5, [-3,5,3]โ5, [5,3,6]โ6, [3,6,7]โ7
Test Cases (2 visible ยท 1 hidden)
Case 1: Classic example
Input: sliding_max([1,3,-1,-3,5,3,6,7],3)
Expected: [3, 3, 5, 5, 6, 7]
Case 2: k=1 returns same
Input: sliding_max([1,2,3],1)
Expected: [1, 2, 3]
โโต Run ยท โโงโต Submit