One way of implementing global limit for is allowed is to use a counting semaphore with value m.then inside is allowed function try acquiring it a timeout that is acceptable..if yes then continue else handle the timeout and return false..also release the semaphore just before returning true..
I feel like this is more for a distributed system, where there's threads and one adds to a bucket while another removes. I think the simple approach here is easier to code and better in interview environment
I've done lots of coding questions and still learned from this, well done! This guy knows his monotonic stacks as well which is rare
One way of implementing global limit for is allowed is to use a counting semaphore with value m.then inside is allowed function try acquiring it a timeout that is acceptable..if yes then continue else handle the timeout and return false..also release the semaphore just before returning true..
I would have said token bucket for global admission control. By global i mean all requests on the server. Anyone think of a better approach?
I feel like this is more for a distributed system, where there's threads and one adds to a bucket while another removes. I think the simple approach here is easier to code and better in interview environment