You operate a small "shield" in front of a busy API. Requests arrive at integer seconds. You can keep at most B requests waiting in a buffer. When the buffer is full and new requests arrive, the newest arrivals beyond capacity must be dropped.
The API enforces two rolling send limits at the same time: across any W1-second window, at most M1 sends are allowed; across any W2-second window, at most M2 sends are allowed. At each second you may send any number of buffered requests as long as both rolling limits are respected. Send from the front of the buffer (FIFO). If the buffer overflows at a second, discard the newest arrivals at that second until the buffer size becomes B. Your goal is to minimize the number of dropped requests and report that minimum.
Implement the function minDropped which takes the request timestamps and the two rolling limits plus buffer size, and returns the minimum number of dropped requests.
An int — the minimal number of dropped requests following the rules.