dsa2 min read
Time Based Key-Value Store — HashMap + Binary Search
Design a time-stamped key-value store supporting set and get(key, timestamp) using binary search on sorted timestamps.
Read →
webcoderspeed.com
1276 articles
Design a time-stamped key-value store supporting set and get(key, timestamp) using binary search on sorted timestamps.
Count 4-tuples summing to zero by splitting into two pairs and using a frequency map of pair sums.
Implement an LFU cache with O(1) get/put using three hash maps: key→val, key→freq, freq→OrderedDict.
Design a data structure supporting inc/dec and getMaxKey/getMinKey in O(1) using a doubly linked list of frequency buckets.
Design Twitter with follow/unfollow and getNewsFeed using per-user tweet lists and a min-heap merge.