Count Valid Tokens
The other question asked in the same batch is LC647.
After a user logs in, they receive a token. If the token exceeds the system-defined expiration period (expiryLimit), it becomes invalid. However, if the token is reset within the period, the expiration time is extended.
Valid tokens can be reset repeatedly. Expired or non-existent tokens will have their reset operations ignored. Expired tokens cannot be used again.
Command format: [type, token_id, T]
Initially, there are no tokens. Process the requests in order and determine how many tokens are still valid at the maximum time point.
Complete the function countValidTokens in the editor.
countValidTokens has the following parameters:
- 1.
int expiryLimit: the system-defined expiration period - 2.
int[][] commands: a 2D array of commands where each command is of the format [type, token_id, T]
Returns
int: the number of valid tokens at the maximum time point