Design - cocoder39/coco39_LC GitHub Wiki

hash

stack & queue

monotonic stack

monotonic queue

array

hashtable (O(1) indexing) + Doubly linked list (maintain order + O(1) insertion and deletion)

  • 460. LFU Cache
  • 146. LRU Cache (record min freq O(1) instead of maintaining freq in sorted data structure O(log N), similar technique is used in 895. Maximum Frequency Stack to identify min or max frequency in O(1)))