An electronic market-making gateway at Citadel processes an incoming stream of client order requests. To safeguard low-latency order matching engines and prevent cascading exchange connectivity failures, the gateway enforces three simultaneous sliding-window throttling rules:
You are given an array of integers request_times sorted in non-decreasing order, where each element represents the arrival timestamp (in seconds) of a client request. A request arriving at time is dropped if processing it would cause the number of recorded requests in any of the three windows ending at to exceed the respective limit.
Crucial Protocol Specification: All requests (both successfully delivered and dropped) remain logged in the gateway's sequence and are counted in the evaluation of all subsequent throttling windows.
Your Task
Implement the function count_dropped_requests(request_times: list[int]) -> int that calculates the total number of dropped order requests.
Constraints
request_times is sorted in non-decreasing order ().Examples
# Example 1
request_times = [1, 1, 1, 1, 2]
# Output: 1 (at index 3, 4th request at t=1 exceeds 3 requests per 1 sec)
# Example 2
request_times = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]
# Output: 2