Back to problems

Hit Counter and Simple Rate Limiter

Object-Oriented Programming · Uber · Medium

You are asked to design two related components and then solve three coding tasks. Part 1: Five-Minute Hit Counter Design an in-memory counter that records events and answers recent-window queries. API: hit(timestamp): record one hit at second timestamp. getHits(timestamp): return the number of hits with timestamps t such that $$timestamp - 300 bool Return true if the number of requests by userId with timestamps in the window $$(timestamp - W,\; timestamp]$$ before this…

Checking your access…