Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 132 #272

Closed
vaskoz opened this issue Jan 1, 2019 · 1 comment
Closed

Day 132 #272

vaskoz opened this issue Jan 1, 2019 · 1 comment
Assignees

Comments

@vaskoz
Copy link
Owner

vaskoz commented Jan 1, 2019

Good morning! Here's your coding interview problem for today.

This question was asked by Riot Games.

Design and implement a HitCounter class that keeps track of requests (or hits). It should support the following operations:

record(timestamp): records a hit that happened at timestamp
total(): returns the total number of hits recorded
range(lower, upper): returns the number of hits that occurred between timestamps lower and upper (inclusive)

Follow-up: What if our system has limited memory?

@vaskoz vaskoz self-assigned this Jan 1, 2019
@vaskoz vaskoz mentioned this issue Jan 1, 2019
@vaskoz
Copy link
Owner Author

vaskoz commented Jan 2, 2019

I did the brute force solution where range takes O(N) time. This can be reduced to O(log N) time by a self-balancing binary search tree.

@vaskoz vaskoz mentioned this issue Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant