Message rate limiter
Implement a logger rate limiter. Given a chronologically ordered list of `[timestamp, message]` requests, a message should be printed only if it has not been printed in the last 10 seconds, meaning at least 10 seconds have elapsed since the last time it printed. Return a list of booleans, one per request, indicating whether each message is allowed to print. Timestamps are non-decreasing.
Implement
rate_limited(requests: list[list]) → list[bool]Examples
in
[[[1,"foo"],[2,"bar"],[3,"foo"]]]out[true,true,false]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 20 min
solution.py
InputExpectedGot
[[[1,"foo"],[2,"bar"],[3,"foo"]]][true,true,false]not run yetsample