Active Session Tokens
Preview mode. Log in to edit, run, submit, and save progress.
Medium
Active Session Tokens
A login service manages temporary access passes. A create command starts a pass that expires after expiryLimit time units. A reset command extends an existing pass only if it has not expired yet. After all commands are processed, return how many passes are still active at the time of the last command.
Examples
Example 1
Input:
5 3 0 1 1 1 1 3 0 2 7
Output:
2
Approach hint
A token is active at time T only if its expiry time is greater than T.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp