HardPro challengePythonJavaScriptTypeScript
Throttle Stream
BackendStreamsThrottle
Given input events [time, value], emit at most one event per window ms.
Always emit the first event. Subsequent events within the window are dropped.
solve(window, events) returns the emitted values in order.
Sample tests
Test #1"b" dropped
Input: [100,[[0,"a"],[50,"b"],[100,"c"]]]
Output: ["a","c"]
Test #2Both pass
Input: [100,[[0,"a"],[200,"b"]]]
Output: ["a","b"]
Test #3Empty
Input: [50,[]]
Output: []
Test #4Half emitted
Input: [10,[[0,1],[5,2],[10,3],[15,4]]]
Output: [1,3]
Test #5Single event
Input: [1000,[[0,"x"]]]
Output: ["x"]