Object-Oriented Programming · Amazon · Medium
Build a rate limiter for log messages. Each incoming log request is a pair (timestamp, message), and requests reach you with timestamps that never decrease. Provide the method shouldPrintMessage(timestamp, message), which decides whether the given request may be printed. The method answers true in either of two situations: the message has not been printed at any earlier point, or 10 seconds or more have passed since the last moment this same message was allowed through. In…