Practice Design Authentication Manager
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Design Authentication Manager
Problem Statement
AuthenticationManager(timeToLive) tracks token expiry. generate(tokenId,currentTime) creates a token expiring at currentTime + timeToLive. renew extends an existing unexpired token from the renewal time; absent or expired tokens are ignored. countUnexpiredTokens returns the number still valid. Expiration happens before other actions at the same time. Practice approach: Store token-to-expiry mappings and compare expiry strictly greater than the current time. A scan suffices for 2000 calls; a time-ordered structure can expire older entries efficiently. Do not renew a token at its expiry instant. Test exact expiry and absent-token renewal.
Source: Design Authentication Manager on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
["AuthenticationManager","generate","countUnexpiredTokens","renew","countUnexpiredTokens"] [[3],["a",1],[3],["a",4],[5]]
[null,null,1,null,0]
Token a expires at time 4. Its renewal at exactly 4 is ignored.
Constraints
Related LeetCode Problems
Practice more problems similar to Design Authentication Manager.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.