linkjobai / Time-Based Key-Value Store (LeetCode 981): Binary Search on Timestamps
0 likes
0 forks
1 files
Last active 5 days ago
Interview prep notes
Time-Based Key-Value Store (LeetCode 981): Binary Search on Timestamps
The problem: implement set(key, value, timestamp) and get(key, timestamp), where get returns the value set at the largest timestamp less than or equal to the one requested.
Key observation
Timestamps for each key arrive in increasing order. So every key's history is already a sorted list, and get is a binary search.
import bisect
Newer
Older