Skip to content

Instantly share code, notes, and snippets.

@Semant1ka
Created January 18, 2022 16:56
Show Gist options
  • Save Semant1ka/5564ba2b805192f0c4b6328cd24263a7 to your computer and use it in GitHub Desktop.
Save Semant1ka/5564ba2b805192f0c4b6328cd24263a7 to your computer and use it in GitHub Desktop.
362. Design Hit Counter
class HitCounter:
def __init__(self):
self.counters = dict()
def hit(self, timestamp: int) -> None:
self.counters[timestamp] = self.counters.get(timestamp, 0) + 1
def getHits(self, timestamp: int) -> int:
return sum([v for k,v in self.counters.items() if k <= timestamp and timestamp - k < 300])
@Semant1ka
Copy link
Author

make public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment