NeetCode #957LC-2622MediumJavaScript
← Back to All Problems#957 · #2622 · Cache With Time Limit(有时间限制的缓存)
📌 Problem Statement & Constraints
Implement a
TimeLimitedCache class: set(key, value, duration) stores an entry and returns whether the key already existed and was unexpired; get(key) returns the value if unexpired, otherwise -1; count() returns the number of unexpired entries. Constraints: at most 2 * 10^5 calls.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!