Medium data structure and algorithm practice puzzle.
Given request timestamps in order, a window length and a limit, return how many requests are allowed. A request is allowed when fewer than `limit` allowed requests fall inside the window ending at its arrival; a rejected request costs nothing and does not fill the budget. This is the shape of the limiter guarding the sign-in and certificate routes on this site, and the window is the whole reason a burst at the boundary cannot slip through twice.
Solve it three ways: snap the jigsaw pieces together, fill in the blanks, or type it from scratch against the tests. This one is free.
Browse all 536 puzzles