AlgoMaster Logo

Logger Rate Limiter

operations=[{"timestamp":1,"message":"foo"},{"timestamp":2,"message":"bar"},{"timestamp":3,"message":"foo"},{"timestamp":8,"message":"bar"},{"timestamp":10,"message":"foo"},{"timestamp":11,"message":"foo"}]
0 / 13
printed = 0blocked = 0t12381011foobarfoobarfoofootime05101520mapempty
algomaster.io
Step:Start: track each message's nextAllowed time in a hash map. A message may print again only when timestamp >= nextAllowed.