138. Counting Recent Accesses
A system receives access registration and query operations, each associated with a time in seconds. Operation times arrive in non-decreasing order.
The possible operations are registrar, which records an access at the given time, and contar, which asks how many accesses were recorded in the last 300 seconds, including the current time. For a query at time t, count accesses recorded at times from t - 299 through t, inclusive.
Receive the operations in operacoes and their corresponding times in valores. Both lists have the same length. Return a list with one result per operation: null for each registration and the access count for each query, in the same order as the operations.
- 0 <= operacoes.length <= 10^5
- operacoes.length == valores.length
- Each element of operacoes is either "registrar" or "contar".
- 0 <= valores[i] <= 10^9
- valores is in non-decreasing order.
Run checks these 2 cases. Submit runs all 11, including hidden ones.