Design a rate limiter, similar to https://leetcode.com/problems/design-hit-counter/description/
But the catch is, for follow up, Apple asked me to do in constant time and Coupang asked me if i can do it with constant space.
Any ideas on either of those?
My thoughts:
For constant time, Even if you use circular array, you need to move the pointer some k spaces.
What if we store a running count and use the difference to calculate the current hits?
For constant space, i have no idea.