Design Hit Counter
Asked at Uber · Coding Questions · Difficulty: Easy · Last asked Mar 23, 2026
Design a hit counter that counts hits received in the past 5 minutes (300 seconds). Implement `HitCounter`: `hit(timestamp)` records a hit at `timestamp` (seconds; several hits may share a timestamp); `getHits(timestamp)` returns the number of hits in the past 300 seconds from `timestamp`. Calls arrive in chronological order (timestamp monotonically increasing).
Loading the problem…